ETH Price: $3,266.96 (+0.62%)

Contract

0x5dc60BC57d7846EEB5C046345950c69224C83b6E
 
Transaction Hash
Method
Block
From
To
Remove ETH Liqui...129860782021-08-08 18:28:021251 days ago1628447282IN
0x5dc60BC5...224C83b6E
0 ETH0.0021635965
Make Trade129575262021-08-04 8:14:181256 days ago1628064858IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade129473022021-08-02 17:38:001257 days ago1627925880IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade129099982021-07-27 19:41:561263 days ago1627414916IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade129066482021-07-27 6:44:561264 days ago1627368296IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade129023422021-07-26 14:23:211265 days ago1627309401IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128934202021-07-25 4:44:471266 days ago1627188287IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128933702021-07-25 4:36:071266 days ago1627187767IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128865742021-07-24 3:21:561267 days ago1627096916IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128859082021-07-24 0:59:141267 days ago1627088354IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128808742021-07-23 5:57:191268 days ago1627019839IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128792982021-07-22 23:56:441268 days ago1626998204IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128791602021-07-22 23:23:331268 days ago1626996213IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128791492021-07-22 23:22:011268 days ago1626996121IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128791432021-07-22 23:20:581268 days ago1626996058IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128753142021-07-22 9:18:271269 days ago1626945507IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128751262021-07-22 8:38:291269 days ago1626943109IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128688892021-07-21 9:10:081270 days ago1626858608IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128684082021-07-21 7:16:361270 days ago1626851796IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128678412021-07-21 5:09:431270 days ago1626844183IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128678302021-07-21 5:06:191270 days ago1626843979IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128386512021-07-16 15:15:371275 days ago1626448537IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128354022021-07-16 3:00:331275 days ago1626404433IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade128191752021-07-13 13:56:151278 days ago1626184575IN
0x5dc60BC5...224C83b6E
0 ETH00
Make Trade127706942021-07-06 0:22:211285 days ago1625530941IN
0x5dc60BC5...224C83b6E
0 ETH00
View all transactions

Latest 25 internal transactions (View All)

Advanced mode:
Parent Transaction Hash Block
From
To
147884492022-05-16 20:53:21970 days ago1652734401
0x5dc60BC5...224C83b6E
22.17718916 ETH
129860782021-08-08 18:28:021251 days ago1628447282
0x5dc60BC5...224C83b6E
81 ETH
129575262021-08-04 8:14:181256 days ago1628064858
0x5dc60BC5...224C83b6E
2.04462357 ETH
129575262021-08-04 8:14:181256 days ago1628064858
0x5dc60BC5...224C83b6E
2.03 ETH
129473022021-08-02 17:38:001257 days ago1627925880
0x5dc60BC5...224C83b6E
3.52641213 ETH
129473022021-08-02 17:38:001257 days ago1627925880
0x5dc60BC5...224C83b6E
3.51 ETH
129099982021-07-27 19:41:561263 days ago1627414916
0x5dc60BC5...224C83b6E
2.09367963 ETH
129099982021-07-27 19:41:561263 days ago1627414916
0x5dc60BC5...224C83b6E
2.09090589 ETH
129066482021-07-27 6:44:561264 days ago1627368296
0x5dc60BC5...224C83b6E
1.08115842 ETH
129066482021-07-27 6:44:561264 days ago1627368296
0x5dc60BC5...224C83b6E
1.08038512 ETH
129023422021-07-26 14:23:211265 days ago1627309401
0x5dc60BC5...224C83b6E
2.11288534 ETH
129023422021-07-26 14:23:211265 days ago1627309401
0x5dc60BC5...224C83b6E
2.11 ETH
128934202021-07-25 4:44:471266 days ago1627188287
0x5dc60BC5...224C83b6E
2.81634992 ETH
128934202021-07-25 4:44:471266 days ago1627188287
0x5dc60BC5...224C83b6E
2.81 ETH
128933702021-07-25 4:36:071266 days ago1627187767
0x5dc60BC5...224C83b6E
0.97494852 ETH
128933702021-07-25 4:36:071266 days ago1627187767
0x5dc60BC5...224C83b6E
0.97434437 ETH
128865742021-07-24 3:21:561267 days ago1627096916
0x5dc60BC5...224C83b6E
1.7012833 ETH
128865742021-07-24 3:21:561267 days ago1627096916
0x5dc60BC5...224C83b6E
1.69940245 ETH
128859082021-07-24 0:59:141267 days ago1627088354
0x5dc60BC5...224C83b6E
1.45054293 ETH
128859082021-07-24 0:59:141267 days ago1627088354
0x5dc60BC5...224C83b6E
1.44916119 ETH
128808742021-07-23 5:57:191268 days ago1627019839
0x5dc60BC5...224C83b6E
2.75072989 ETH
128808742021-07-23 5:57:191268 days ago1627019839
0x5dc60BC5...224C83b6E
2.74567797 ETH
128792982021-07-22 23:56:441268 days ago1626998204
0x5dc60BC5...224C83b6E
1.81433735 ETH
128792982021-07-22 23:56:441268 days ago1626998204
0x5dc60BC5...224C83b6E
1.81207329 ETH
128791602021-07-22 23:23:331268 days ago1626996213
0x5dc60BC5...224C83b6E
3.2962322 ETH
View All Internal Transactions
Loading...
Loading

Similar Match Source Code
This contract matches the deployed Bytecode of the Source Code for Contract 0x4dDCb6a1...59b9C3d82
The constructor portion of the code might be different and could alter the actual behaviour of the contract

Contract Name:
Dispatcher

Compiler Version
v0.7.4+commit.3f05b770

Optimization Enabled:
Yes with 9999 runs

Other Settings:
default evmVersion
File 1 of 13 : Dispatcher.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;
pragma experimental ABIEncoderV2;

import "./interfaces/IERC20.sol";
import "./interfaces/IQueryEngine.sol";

import "./lib/SafeMath.sol";
import "./lib/SafeERC20.sol";
import "./lib/AccessControl.sol";
import "./lib/Trader.sol";

/**
 * @title Dispatcher
 * @dev Executes trades on behalf of suppliers and maintains bankroll to support supplier strategies
 */
contract Dispatcher is AccessControl, Trader {
    // Allows safe math operations on uint256 values
    using SafeMath for uint256;

    // Allows easy manipulation on bytes
    using BytesLib for bytes;

    // Use safe ERC20 interface to gracefully handle non-compliant tokens
    using SafeERC20 for IERC20;

    /// @notice Version number of Dispatcher
    uint8 public version;

    /// @notice Admin role to manage whitelisted LPs
    bytes32 public constant MANAGE_LP_ROLE = keccak256("MANAGE_LP_ROLE");

    /// @notice Addresses with this role are allowed to provide liquidity to this contract
    /// @dev If no addresses with this role exist, all addresses can provide liquidity
    bytes32 public constant WHITELISTED_LP_ROLE = keccak256("WHITELISTED_LP_ROLE");

    /// @notice Admin role to restrict approval of tokens on dispatcher
    bytes32 public constant APPROVER_ROLE = keccak256("APPROVER_ROLE");  

    /// @notice Admin role to restrict withdrawal of funds from contract
    bytes32 public constant WITHDRAW_ROLE = keccak256("WITHDRAW_ROLE");    

    /// @notice Maximum ETH liquidity allowed in Dispatcher
    uint256 public MAX_LIQUIDITY;

    /// @notice Total current liquidity provided to Dispatcher
    uint256 public totalLiquidity;

    /// @notice Mapping of lp address to liquidity provided
    mapping(address => uint256) public lpBalances;

    /// @notice modifier to restrict functions to only users that have been added as LP manager
    modifier onlyLPManager() {
        require(hasRole(MANAGE_LP_ROLE, msg.sender), "Caller must have MANAGE_LP role");
        _;
    }

    /// @notice modifier to restrict functions to only users that have been added as an approver
    modifier onlyApprover() {
        require(hasRole(APPROVER_ROLE, msg.sender), "Caller must have APPROVER role");
        _;
    }

    /// @notice modifier to restrict functions to only users that have been added as a withdrawer
    modifier onlyWithdrawer() {
        require(hasRole(WITHDRAW_ROLE, msg.sender), "Caller must have WITHDRAW role");
        _;
    }

    /// @notice modifier to restrict functions to only users that have been whitelisted as an LP
    modifier onlyWhitelistedLP() {
        if(getRoleMemberCount(WHITELISTED_LP_ROLE) > 0) {
            require(hasRole(WHITELISTED_LP_ROLE, msg.sender), "Caller must have WHITELISTED_LP role");
        }
        _;
    }

    /// @notice Max liquidity updated event
    event MaxLiquidityUpdated(address indexed asset, uint256 indexed newAmount, uint256 oldAmount);

    /// @notice Liquidity Provided event
    event LiquidityProvided(address indexed asset, address indexed provider, uint256 amount);

    /// @notice Liquidity removed event
    event LiquidityRemoved(address indexed asset, address indexed provider, uint256 amount);

    /// @notice Initializes contract, setting up initial contract permissions
    /// @param _version Version number of Dispatcher
    /// @param _queryEngine Address of query engine contract
    /// @param _roleManager Address allowed to manage contract roles
    /// @param _lpManager Address allowed to manage LP whitelist
    /// @param _withdrawer Address allowed to withdraw profit from contract
    /// @param _trader Address allowed to make trades via this contract
    /// @param _supplier Address allowed to send opportunities to this contract
    /// @param _initialMaxLiquidity Initial max liquidity allowed in contract
    /// @param _lpWhitelist List of addresses that are allowed to provide liquidity to this contract
    constructor(
        uint8 _version,
        address _queryEngine,
        address _roleManager,
        address _lpManager,
        address _withdrawer,
        address _trader,
        address _supplier,
        uint256 _initialMaxLiquidity,
        address[] memory _lpWhitelist
    ) {
        version = _version;
        queryEngine = IQueryEngine(_queryEngine);
        _setupRole(MANAGE_LP_ROLE, _lpManager);
        _setRoleAdmin(WHITELISTED_LP_ROLE, MANAGE_LP_ROLE);
        _setupRole(WITHDRAW_ROLE, _withdrawer);
        _setupRole(TRADER_ROLE, _trader);
        _setupRole(APPROVER_ROLE, _supplier);
        _setupRole(APPROVER_ROLE, _withdrawer);
        _setupRole(DEFAULT_ADMIN_ROLE, _roleManager);
        MAX_LIQUIDITY = _initialMaxLiquidity;
        for(uint i; i < _lpWhitelist.length; i++) {
            _setupRole(WHITELISTED_LP_ROLE, _lpWhitelist[i]);
        }
    }

    /// @notice Receive function to allow contract to accept ETH
    receive() external payable {}
    
    /// @notice Fallback function in case receive function is not matched
    fallback() external payable {}

    /// @notice Returns true if given address is on the list of approvers
    /// @param addressToCheck the address to check
    /// @return true if address is approver
    function isApprover(address addressToCheck) external view returns(bool) {
        return hasRole(APPROVER_ROLE, addressToCheck);
    }

    /// @notice Returns true if given address is on the list of approved withdrawers
    /// @param addressToCheck the address to check
    /// @return true if address is withdrawer
    function isWithdrawer(address addressToCheck) external view returns(bool) {
        return hasRole(WITHDRAW_ROLE, addressToCheck);
    }

    /// @notice Returns true if given address is on the list of LP managers
    /// @param addressToCheck the address to check
    /// @return true if address is LP manager
    function isLPManager(address addressToCheck) external view returns(bool) {
        return hasRole(MANAGE_LP_ROLE, addressToCheck);
    }

    /// @notice Returns true if given address is on the list of whitelisted LPs
    /// @param addressToCheck the address to check
    /// @return true if address is whitelisted
    function isWhitelistedLP(address addressToCheck) external view returns(bool) {
        return hasRole(WHITELISTED_LP_ROLE, addressToCheck);
    }

    /// @notice Set approvals for external addresses to use Dispatcher contract tokens
    /// @param tokensToApprove the tokens to approve
    /// @param spender the address to allow spending of token
    function tokenAllowAll(
        address[] memory tokensToApprove, 
        address spender
    ) external onlyApprover {
        for(uint i = 0; i < tokensToApprove.length; i++) {
            IERC20 token = IERC20(tokensToApprove[i]);
            if (token.allowance(address(this), spender) != uint256(-1)) {
                token.safeApprove(spender, uint256(-1));
            }
        }
    }

    /// @notice Set approvals for external addresses to use Dispatcher contract tokens
    /// @param tokensToApprove the tokens to approve
    /// @param approvalAmounts the token approval amounts
    /// @param spender the address to allow spending of token
    function tokenAllow(
        address[] memory tokensToApprove, 
        uint256[] memory approvalAmounts, 
        address spender
    ) external onlyApprover {
        require(tokensToApprove.length == approvalAmounts.length, "not same length");
        for(uint i = 0; i < tokensToApprove.length; i++) {
            IERC20 token = IERC20(tokensToApprove[i]);
            if (token.allowance(address(this), spender) != uint256(-1)) {
                token.safeApprove(spender, approvalAmounts[i]);
            }
        }
    }

    /// @notice Rescue (withdraw) tokens from the smart contract
    /// @param tokens the tokens to withdraw
    /// @param amount the amount of each token to withdraw.  If zero, withdraws the maximum allowed amount for each token
    function rescueTokens(address[] calldata tokens, uint256 amount) external onlyWithdrawer {
        for (uint i = 0; i < tokens.length; i++) {
            IERC20 token = IERC20(tokens[i]);
            uint256 withdrawalAmount;
            uint256 tokenBalance = token.balanceOf(address(this));
            uint256 tokenAllowance = token.allowance(address(this), msg.sender);
            if (amount == 0) {
                if (tokenBalance > tokenAllowance) {
                    withdrawalAmount = tokenAllowance;
                } else {
                    withdrawalAmount = tokenBalance;
                }
            } else {
                require(tokenBalance >= amount, "Contract balance too low");
                require(tokenAllowance >= amount, "Increase token allowance");
                withdrawalAmount = amount;
            }
            token.safeTransferFrom(address(this), msg.sender, withdrawalAmount);
        }
    }

    /// @notice Set max ETH liquidity to accept for this contract
    /// @param newMax new max ETH liquidity
    function setMaxETHLiquidity(uint256 newMax) external onlyLPManager {
        emit MaxLiquidityUpdated(address(0), newMax, MAX_LIQUIDITY);
        MAX_LIQUIDITY = newMax;
    }

    /// @notice Provide ETH liquidity to Dispatcher
    function provideETHLiquidity() external payable onlyWhitelistedLP {
        require(totalLiquidity.add(msg.value) <= MAX_LIQUIDITY, "amount exceeds max liquidity");
        totalLiquidity = totalLiquidity.add(msg.value);
        lpBalances[msg.sender] = lpBalances[msg.sender].add(msg.value);
        emit LiquidityProvided(address(0), msg.sender, msg.value);
    }

    /// @notice Remove ETH liquidity from Dispatcher
    /// @param amount amount of liquidity to remove
    function removeETHLiquidity(uint256 amount) external {
        require(lpBalances[msg.sender] >= amount, "amount exceeds liquidity provided");
        require(totalLiquidity.sub(amount) >= 0, "amount exceeds total liquidity");
        require(address(this).balance.sub(amount) >= 0, "amount exceeds contract balance");
        lpBalances[msg.sender] = lpBalances[msg.sender].sub(amount);
        totalLiquidity = totalLiquidity.sub(amount);
        (bool success, ) = msg.sender.call{value: amount}("");
        require(success, "Could not withdraw ETH");
        emit LiquidityRemoved(address(0), msg.sender, amount);
    }

    /// @notice Withdraw ETH from the smart contract
    /// @param amount the amount of ETH to withdraw.  If zero, withdraws the maximum allowed amount.
    function withdrawEth(uint256 amount) external onlyWithdrawer {
        uint256 withdrawalAmount;
        uint256 withdrawableBalance = address(this).balance.sub(totalLiquidity);
        if (amount == 0) {
            withdrawalAmount = withdrawableBalance;
        } else {
            require(withdrawableBalance >= amount, "amount exceeds withdrawable balance");
            withdrawalAmount = amount;
        }
        (bool success, ) = msg.sender.call{value: withdrawalAmount}("");
        require(success, "Could not withdraw ETH");
    }

    /// @notice A non-view function to help estimate the cost of a given query in practice
    /// @param script the compiled bytecode for the series of function calls to get the final price
    /// @param inputLocations index locations within the script to insert input amounts dynamically
    function estimateQueryCost(bytes memory script, uint256[] memory inputLocations) public {
        queryEngine.queryAllPrices(script, inputLocations);
    }
}

File 2 of 13 : IERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

interface IERC20 {
    function name() external view returns (string memory);
    function symbol() external view returns (string memory);
    function decimals() external view returns (uint8);
    function totalSupply() external view returns (uint256);
    function balanceOf(address account) external view returns (uint256);
    function transfer(address recipient, uint256 amount) external returns (bool);
    function allowance(address owner, address spender) external view returns (uint256);
    function approve(address spender, uint256 amount) external returns (bool);
    function transferFrom(address sender, address recipient, uint256 amount) external returns (bool);
    event Transfer(address indexed from, address indexed to, uint256 value);
    event Approval(address indexed owner, address indexed spender, uint256 value);
}

File 3 of 13 : IQueryEngine.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

interface IQueryEngine {
    function getPrice(address contractAddress, bytes memory data) external view returns (bytes memory);
    function queryAllPrices(bytes memory script, uint256[] memory inputLocations) external view returns (bytes memory);
    function query(bytes memory script, uint256[] memory inputLocations) external view returns (uint256);
}

File 4 of 13 : SafeMath.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

// From https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/math/Math.sol
// Subject to the MIT license.

/**
 * @dev Wrappers over Solidity's arithmetic operations with added overflow
 * checks.
 *
 * Arithmetic operations in Solidity wrap on overflow. This can easily result
 * in bugs, because programmers usually assume that an overflow raises an
 * error, which is the standard behavior in high level programming languages.
 * `SafeMath` restores this intuition by reverting the transaction when 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.
 */
library SafeMath {
    /**
     * @dev Returns the addition of two unsigned integers, reverting on overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, "SafeMath: addition overflow");

        return c;
    }

    /**
     * @dev Returns the addition of two unsigned integers, reverting with custom message on overflow.
     *
     * Counterpart to Solidity's `+` operator.
     *
     * Requirements:
     * - Addition cannot overflow.
     */
    function add(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        uint256 c = a + b;
        require(c >= a, errorMessage);

        return c;
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting on underflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot underflow.
     */
    function sub(uint256 a, uint256 b) internal pure returns (uint256) {
        return sub(a, b, "SafeMath: subtraction underflow");
    }

    /**
     * @dev Returns the subtraction of two unsigned integers, reverting with custom message on underflow (when the result is negative).
     *
     * Counterpart to Solidity's `-` operator.
     *
     * Requirements:
     * - Subtraction cannot underflow.
     */
    function sub(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b <= a, errorMessage);
        uint256 c = a - b;

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, "SafeMath: multiplication overflow");

        return c;
    }

    /**
     * @dev Returns the multiplication of two unsigned integers, reverting on overflow.
     *
     * Counterpart to Solidity's `*` operator.
     *
     * Requirements:
     * - Multiplication cannot overflow.
     */
    function mul(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the
        // benefit is lost if 'b' is also tested.
        // See: https://github.com/OpenZeppelin/openzeppelin-contracts/pull/522
        if (a == 0) {
            return 0;
        }

        uint256 c = a * b;
        require(c / a == b, errorMessage);

        return c;
    }

    /**
     * @dev Returns the integer division of two unsigned integers.
     * Reverts on division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b) internal pure returns (uint256) {
        return div(a, b, "SafeMath: division by zero");
    }

    /**
     * @dev Returns the integer division of two unsigned integers.
     * Reverts with custom message on division by zero. The result is rounded towards zero.
     *
     * Counterpart to Solidity's `/` operator. Note: this function uses a
     * `revert` opcode (which leaves remaining gas untouched) while Solidity
     * uses an invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function div(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        // Solidity only automatically asserts when dividing by 0
        require(b > 0, errorMessage);
        uint256 c = a / b;
        // assert(a == b * c + a % b); // There is no case in which this doesn't hold

        return c;
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b) internal pure returns (uint256) {
        return mod(a, b, "SafeMath: modulo by zero");
    }

    /**
     * @dev Returns the remainder of dividing two unsigned integers. (unsigned integer modulo),
     * Reverts with custom message when dividing by zero.
     *
     * Counterpart to Solidity's `%` operator. This function uses a `revert`
     * opcode (which leaves remaining gas untouched) while Solidity uses an
     * invalid opcode to revert (consuming all remaining gas).
     *
     * Requirements:
     * - The divisor cannot be zero.
     */
    function mod(uint256 a, uint256 b, string memory errorMessage) internal pure returns (uint256) {
        require(b != 0, errorMessage);
        return a % b;
    }
}

File 5 of 13 : SafeERC20.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "../interfaces/IERC20.sol";
import "./SafeMath.sol";
import "./Address.sol";

/**
 * @title SafeERC20
 * @dev Wrappers around ERC20 operations that throw on failure (when the token
 * contract returns false). Tokens that return no value (and instead revert or
 * throw on failure) are also supported, non-reverting calls are assumed to be
 * successful.
 * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,
 * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.
 */
library SafeERC20 {
    using SafeMath for uint256;
    using Address for address;

    function safeTransfer(IERC20 token, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));
    }

    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) internal {
        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));
    }

    /**
     * @dev Deprecated. This function has issues similar to the ones found in
     * {IERC20-approve}, and its usage is discouraged.
     *
     * Whenever possible, use {safeIncreaseAllowance} and
     * {safeDecreaseAllowance} instead.
     */
    function safeApprove(IERC20 token, address spender, uint256 value) internal {
        // safeApprove should only be called when setting an initial allowance,
        // or when resetting it to zero. To increase and decrease it, use
        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'
        // solhint-disable-next-line max-line-length
        require((value == 0) || (token.allowance(address(this), spender) == 0),
            "SafeERC20: approve from non-zero to non-zero allowance"
        );
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));
    }

    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).add(value);
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {
        uint256 newAllowance = token.allowance(address(this), spender).sub(value, "SafeERC20: decreased allowance below zero");
        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));
    }

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

        bytes memory returndata = address(token).functionCall(data, "SafeERC20: low-level call failed");
        if (returndata.length > 0) { // Return data is optional
            // solhint-disable-next-line max-line-length
            require(abi.decode(returndata, (bool)), "SafeERC20: ERC20 operation did not succeed");
        }
    }
}

File 6 of 13 : AccessControl.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

import "./EnumerableSet.sol";
import "./Address.sol";
import "./Context.sol";

/**
 * @dev Contract module that allows children to implement role-based access
 * control mechanisms.
 *
 * Roles are referred to by their `bytes32` identifier. These should be exposed
 * in the external API and be unique. The best way to achieve this is by
 * using `public constant` hash digests:
 *
 * ```
 * bytes32 public constant MY_ROLE = keccak256("MY_ROLE");
 * ```
 *
 * Roles can be used to represent a set of permissions. To restrict access to a
 * function call, use {hasRole}:
 *
 * ```
 * function foo() public {
 *     require(hasRole(MY_ROLE, msg.sender));
 *     ...
 * }
 * ```
 *
 * Roles can be granted and revoked dynamically via the {grantRole} and
 * {revokeRole} functions. Each role has an associated admin role, and only
 * accounts that have a role's admin role can call {grantRole} and {revokeRole}.
 *
 * By default, the admin role for all roles is `DEFAULT_ADMIN_ROLE`, which means
 * that only accounts with this role will be able to grant or revoke other
 * roles. More complex role relationships can be created by using
 * {_setRoleAdmin}.
 *
 * WARNING: The `DEFAULT_ADMIN_ROLE` is also its own admin: it has permission to
 * grant and revoke this role. Extra precautions should be taken to secure
 * accounts that have been granted it.
 */
abstract contract AccessControl is Context {
    using EnumerableSet for EnumerableSet.AddressSet;
    using Address for address;

    struct RoleData {
        EnumerableSet.AddressSet members;
        bytes32 adminRole;
    }

    mapping (bytes32 => RoleData) private _roles;

    bytes32 public constant DEFAULT_ADMIN_ROLE = 0x00;

    /**
     * @dev Emitted when `newAdminRole` is set as ``role``'s admin role, replacing `previousAdminRole`
     *
     * `DEFAULT_ADMIN_ROLE` is the starting admin for all roles, despite
     * {RoleAdminChanged} not being emitted signaling this.
     *
     * _Available since v3.1._
     */
    event RoleAdminChanged(bytes32 indexed role, bytes32 indexed previousAdminRole, bytes32 indexed newAdminRole);

    /**
     * @dev Emitted when `account` is granted `role`.
     *
     * `sender` is the account that originated the contract call, an admin role
     * bearer except when using {_setupRole}.
     */
    event RoleGranted(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Emitted when `account` is revoked `role`.
     *
     * `sender` is the account that originated the contract call:
     *   - if using `revokeRole`, it is the admin role bearer
     *   - if using `renounceRole`, it is the role bearer (i.e. `account`)
     */
    event RoleRevoked(bytes32 indexed role, address indexed account, address indexed sender);

    /**
     * @dev Returns `true` if `account` has been granted `role`.
     */
    function hasRole(bytes32 role, address account) public view returns (bool) {
        return _roles[role].members.contains(account);
    }

    /**
     * @dev Returns the number of accounts that have `role`. Can be used
     * together with {getRoleMember} to enumerate all bearers of a role.
     */
    function getRoleMemberCount(bytes32 role) public view returns (uint256) {
        return _roles[role].members.length();
    }

    /**
     * @dev Returns one of the accounts that have `role`. `index` must be a
     * value between 0 and {getRoleMemberCount}, non-inclusive.
     *
     * Role bearers are not sorted in any particular way, and their ordering may
     * change at any point.
     *
     * WARNING: When using {getRoleMember} and {getRoleMemberCount}, make sure
     * you perform all queries on the same block. See the following
     * https://forum.openzeppelin.com/t/iterating-over-elements-on-enumerableset-in-openzeppelin-contracts/2296[forum post]
     * for more information.
     */
    function getRoleMember(bytes32 role, uint256 index) public view returns (address) {
        return _roles[role].members.at(index);
    }

    /**
     * @dev Returns the admin role that controls `role`. See {grantRole} and
     * {revokeRole}.
     *
     * To change a role's admin, use {_setRoleAdmin}.
     */
    function getRoleAdmin(bytes32 role) public view returns (bytes32) {
        return _roles[role].adminRole;
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function grantRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to grant");

        _grantRole(role, account);
    }

    /**
     * @dev Revokes `role` from `account`.
     *
     * If `account` had been granted `role`, emits a {RoleRevoked} event.
     *
     * Requirements:
     *
     * - the caller must have ``role``'s admin role.
     */
    function revokeRole(bytes32 role, address account) public virtual {
        require(hasRole(_roles[role].adminRole, _msgSender()), "AccessControl: sender must be an admin to revoke");

        _revokeRole(role, account);
    }

    /**
     * @dev Revokes `role` from the calling account.
     *
     * Roles are often managed via {grantRole} and {revokeRole}: this function's
     * purpose is to provide a mechanism for accounts to lose their privileges
     * if they are compromised (such as when a trusted device is misplaced).
     *
     * If the calling account had been granted `role`, emits a {RoleRevoked}
     * event.
     *
     * Requirements:
     *
     * - the caller must be `account`.
     */
    function renounceRole(bytes32 role, address account) public virtual {
        require(account == _msgSender(), "AccessControl: can only renounce roles for self");

        _revokeRole(role, account);
    }

    /**
     * @dev Grants `role` to `account`.
     *
     * If `account` had not been already granted `role`, emits a {RoleGranted}
     * event. Note that unlike {grantRole}, this function doesn't perform any
     * checks on the calling account.
     *
     * [WARNING]
     * ====
     * This function should only be called from the constructor when setting
     * up the initial roles for the system.
     *
     * Using this function in any other way is effectively circumventing the admin
     * system imposed by {AccessControl}.
     * ====
     */
    function _setupRole(bytes32 role, address account) internal virtual {
        _grantRole(role, account);
    }

    /**
     * @dev Sets `adminRole` as ``role``'s admin role.
     *
     * Emits a {RoleAdminChanged} event.
     */
    function _setRoleAdmin(bytes32 role, bytes32 adminRole) internal virtual {
        emit RoleAdminChanged(role, _roles[role].adminRole, adminRole);
        _roles[role].adminRole = adminRole;
    }

    function _grantRole(bytes32 role, address account) private {
        if (_roles[role].members.add(account)) {
            emit RoleGranted(role, account, _msgSender());
        }
    }

    function _revokeRole(bytes32 role, address account) private {
        if (_roles[role].members.remove(account)) {
            emit RoleRevoked(role, account, _msgSender());
        }
    }
}

File 7 of 13 : Trader.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "../interfaces/IQueryEngine.sol";

import "./BytesLib.sol";
import "./CalldataEditor.sol";
import "./AccessControl.sol";
import "./ReentrancyGuard.sol";

abstract contract Trader is ReentrancyGuard, AccessControl, CalldataEditor {
    using BytesLib for bytes;

    /// @notice Query contract
    IQueryEngine public queryEngine;

    /// @notice Trader role to restrict functions to set list of approved traders
    bytes32 public constant TRADER_ROLE = keccak256("TRADER_ROLE");

    /// @notice modifier to restrict functions to only users that have been added as a trader
    modifier onlyTrader() {
        require(hasRole(TRADER_ROLE, msg.sender), "Trader must have TRADER role");
        _;
    }

    /// @notice All trades must be profitable
    modifier mustBeProfitable(uint256 ethRequested) {
        uint256 contractBalanceBefore = address(this).balance;
        require(contractBalanceBefore >= ethRequested, "Not enough ETH in contract");
        _;
        require(address(this).balance >= contractBalanceBefore, "missing ETH");
    }

    /// @notice Trades must not be expired
    modifier notExpired(uint256 deadlineBlock) {
        require(deadlineBlock >= block.number, "trade expired");
        _;
    }

    /// @notice Trades must be executed within time window
    modifier onTime(uint256 minTimestamp, uint256 maxTimestamp) {
        require(maxTimestamp >= block.timestamp, "trade too late");
        require(minTimestamp <= block.timestamp, "trade too early");
        _;
    }

    /// @notice Returns true if given address is on the list of approved traders
    /// @param addressToCheck the address to check
    /// @return true if address is trader
    function isTrader(address addressToCheck) external view returns (bool) {
        return hasRole(TRADER_ROLE, addressToCheck);
    }

    /// @notice Makes a series of trades as single transaction if profitable without query
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param ethValue the amount of ETH to send with initial contract call
    function makeTrade(
        bytes memory executeScript,
        uint256 ethValue
    ) public onlyTrader nonReentrant mustBeProfitable(ethValue) {
        execute(executeScript, ethValue);
    }

    /// @notice Makes a series of trades as single transaction if profitable without query + block deadline
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param ethValue the amount of ETH to send with initial contract call
    /// @param blockDeadline block number when trade expires
    function makeTrade(
        bytes memory executeScript,
        uint256 ethValue,
        uint256 blockDeadline
    ) public onlyTrader nonReentrant notExpired(blockDeadline) mustBeProfitable(ethValue) {
        execute(executeScript, ethValue);
    }

    /// @notice Makes a series of trades as single transaction if profitable without query + within time window specified
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param ethValue the amount of ETH to send with initial contract call
    /// @param minTimestamp minimum block timestamp to execute trade
    /// @param maxTimestamp maximum timestamp to execute trade
    function makeTrade(
        bytes memory executeScript,
        uint256 ethValue,
        uint256 minTimestamp,
        uint256 maxTimestamp
    ) public onlyTrader nonReentrant onTime(minTimestamp, maxTimestamp) mustBeProfitable(ethValue) {
        execute(executeScript, ethValue);
    }

    /// @notice Makes a series of trades as single transaction if profitable
    /// @param queryScript the compiled bytecode for the series of function calls to get the final price
    /// @param queryInputLocations index locations within the queryScript to insert input amounts dynamically
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param executeInputLocations index locations within the executeScript to insert input amounts dynamically
    /// @param targetPrice profit target for this trade, if ETH>ETH, this should be ethValue + gas estimate * gas price
    /// @param ethValue the amount of ETH to send with initial contract call
    function makeTrade(
        bytes memory queryScript,
        uint256[] memory queryInputLocations,
        bytes memory executeScript,
        uint256[] memory executeInputLocations,
        uint256 targetPrice,
        uint256 ethValue
    ) public onlyTrader nonReentrant mustBeProfitable(ethValue) {
        bytes memory prices = queryEngine.queryAllPrices(queryScript, queryInputLocations);
        require(prices.toUint256(prices.length - 32) >= targetPrice, "Not profitable");
        for(uint i = 0; i < executeInputLocations.length; i++) {
            replaceDataAt(executeScript, prices.slice(i*32, 32), executeInputLocations[i]);
        }
        execute(executeScript, ethValue);
    }

    /// @notice Makes a series of trades as single transaction if profitable + block deadline
    /// @param queryScript the compiled bytecode for the series of function calls to get the final price
    /// @param queryInputLocations index locations within the queryScript to insert input amounts dynamically
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param executeInputLocations index locations within the executeScript to insert input amounts dynamically
    /// @param targetPrice profit target for this trade, if ETH>ETH, this should be ethValue + gas estimate * gas price
    /// @param ethValue the amount of ETH to send with initial contract call
    /// @param blockDeadline block number when trade expires
    function makeTrade(
        bytes memory queryScript,
        uint256[] memory queryInputLocations,
        bytes memory executeScript,
        uint256[] memory executeInputLocations,
        uint256 targetPrice,
        uint256 ethValue,
        uint256 blockDeadline
    ) public onlyTrader nonReentrant notExpired(blockDeadline) mustBeProfitable(ethValue) {
        bytes memory prices = queryEngine.queryAllPrices(queryScript, queryInputLocations);
        require(prices.toUint256(prices.length - 32) >= targetPrice, "Not profitable");
        for(uint i = 0; i < executeInputLocations.length; i++) {
            replaceDataAt(executeScript, prices.slice(i*32, 32), executeInputLocations[i]);
        }
        execute(executeScript, ethValue);
    }

    /// @notice Makes a series of trades as single transaction if profitable + within time window specified
    /// @param queryScript the compiled bytecode for the series of function calls to get the final price
    /// @param queryInputLocations index locations within the queryScript to insert input amounts dynamically
    /// @param executeScript the compiled bytecode for the series of function calls to execute the trade
    /// @param executeInputLocations index locations within the executeScript to insert input amounts dynamically
    /// @param targetPrice profit target for this trade, if ETH>ETH, this should be ethValue + gas estimate * gas price
    /// @param ethValue the amount of ETH to send with initial contract call
    /// @param minTimestamp minimum block timestamp to execute trade
    /// @param maxTimestamp maximum timestamp to execute trade
    function makeTrade(
        bytes memory queryScript,
        uint256[] memory queryInputLocations,
        bytes memory executeScript,
        uint256[] memory executeInputLocations,
        uint256 targetPrice,
        uint256 ethValue,
        uint256 minTimestamp,
        uint256 maxTimestamp
    ) public onlyTrader nonReentrant onTime(minTimestamp, maxTimestamp) mustBeProfitable(ethValue) {
        bytes memory prices = queryEngine.queryAllPrices(queryScript, queryInputLocations);
        require(prices.toUint256(prices.length - 32) >= targetPrice, "Not profitable");
        for(uint i = 0; i < executeInputLocations.length; i++) {
            replaceDataAt(executeScript, prices.slice(i*32, 32), executeInputLocations[i]);
        }
        execute(executeScript, ethValue);
    }

    /// @notice Executes series of function calls as single transaction
    /// @param script the compiled bytecode for the series of function calls to invoke
    /// @param ethValue the amount of ETH to send with initial contract call
    function execute(bytes memory script, uint256 ethValue) internal {
        // sequentially call contract methods
        uint256 location = 0;
        while (location < script.length) {
            address contractAddress = addressAt(script, location);
            uint256 calldataLength = uint256At(script, location + 0x14);
            uint256 calldataStart = location + 0x14 + 0x20;
            bytes memory callData = script.slice(calldataStart, calldataLength);
            if(location == 0) {
                callMethod(contractAddress, callData, ethValue);
            }
            else {
                callMethod(contractAddress, callData, 0);
            }
            location += (0x14 + 0x20 + calldataLength);
        }
    }

    /// @notice Calls the supplied calldata using the supplied contract address
    /// @param contractToCall the contract to call
    /// @param data the call data to execute
    /// @param ethValue the amount of ETH to send with initial contract call
    function callMethod(address contractToCall, bytes memory data, uint256 ethValue) internal {
        bool success;
        bytes memory returnData;
        address payable contractAddress = payable(contractToCall);
        if(ethValue > 0) {
            (success, returnData) = contractAddress.call{value: ethValue}(data);
        } else {
            (success, returnData) = contractAddress.call(data);
        }
        if (!success) {
            string memory revertMsg = getRevertMsg(returnData);
            revert(revertMsg);
        }
    }
}

File 8 of 13 : Address.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.2 <0.8.0;

/**
 * @dev Collection of functions related to the address type
 */
library Address {
    /**
     * @dev Returns true if `account` is a contract.
     *
     * [IMPORTANT]
     * ====
     * It is unsafe to assume that an address for which this function returns
     * false is an externally-owned account (EOA) and not a contract.
     *
     * Among others, `isContract` will return false for the following
     * types of addresses:
     *
     *  - an externally-owned account
     *  - a contract in construction
     *  - an address where a contract will be created
     *  - an address where a contract lived, but was destroyed
     * ====
     */
    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;
        // solhint-disable-next-line no-inline-assembly
        assembly { size := extcodesize(account) }
        return size > 0;
    }

    /**
     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to
     * `recipient`, forwarding all available gas and reverting on errors.
     *
     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost
     * of certain opcodes, possibly making contracts go over the 2300 gas limit
     * imposed by `transfer`, making them unable to receive funds via
     * `transfer`. {sendValue} removes this limitation.
     *
     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].
     *
     * IMPORTANT: because control is transferred to `recipient`, care must be
     * taken to not create reentrancy vulnerabilities. Consider using
     * {ReentrancyGuard} or the
     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].
     */
    function sendValue(address payable recipient, uint256 amount) internal {
        require(address(this).balance >= amount, "Address: insufficient balance");

        // solhint-disable-next-line avoid-low-level-calls, avoid-call-value
        (bool success, ) = recipient.call{ value: amount }("");
        require(success, "Address: unable to send value, recipient may have reverted");
    }

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

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

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

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

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.call{ value: value }(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a static call.
     *
     * _Available since v3.3._
     */
    function functionStaticCall(address target, bytes memory data, string memory errorMessage) internal view returns (bytes memory) {
        require(isContract(target), "Address: static call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.staticcall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

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

    /**
     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],
     * but performing a delegate call.
     *
     * _Available since v3.3._
     */
    function functionDelegateCall(address target, bytes memory data, string memory errorMessage) internal returns (bytes memory) {
        require(isContract(target), "Address: delegate call to non-contract");

        // solhint-disable-next-line avoid-low-level-calls
        (bool success, bytes memory returndata) = target.delegatecall(data);
        return _verifyCallResult(success, returndata, errorMessage);
    }

    function _verifyCallResult(bool success, bytes memory returndata, string memory errorMessage) private pure returns(bytes memory) {
        if (success) {
            return returndata;
        } else {
            // Look for revert reason and bubble it up if present
            if (returndata.length > 0) {
                // The easiest way to bubble the revert reason is using memory via assembly

                // solhint-disable-next-line no-inline-assembly
                assembly {
                    let returndata_size := mload(returndata)
                    revert(add(32, returndata), returndata_size)
                }
            } else {
                revert(errorMessage);
            }
        }
    }
}

File 9 of 13 : EnumerableSet.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

/**
 * @dev Library for managing
 * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive
 * types.
 *
 * Sets have the following properties:
 *
 * - Elements are added, removed, and checked for existence in constant time
 * (O(1)).
 * - Elements are enumerated in O(n). No guarantees are made on the ordering.
 *
 * ```
 * contract Example {
 *     // Add the library methods
 *     using EnumerableSet for EnumerableSet.AddressSet;
 *
 *     // Declare a set state variable
 *     EnumerableSet.AddressSet private mySet;
 * }
 * ```
 *
 * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)
 * and `uint256` (`UintSet`) are supported.
 */
library EnumerableSet {
    // To implement this library for multiple types with as little code
    // repetition as possible, we write it in terms of a generic Set type with
    // bytes32 values.
    // The Set implementation uses private functions, and user-facing
    // implementations (such as AddressSet) are just wrappers around the
    // underlying Set.
    // This means that we can only create new EnumerableSets for types that fit
    // in bytes32.

    struct Set {
        // Storage of set values
        bytes32[] _values;

        // Position of the value in the `values` array, plus 1 because index 0
        // means a value is not in the set.
        mapping (bytes32 => uint256) _indexes;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function _add(Set storage set, bytes32 value) private returns (bool) {
        if (!_contains(set, value)) {
            set._values.push(value);
            // The value is stored at length-1, but we add 1 to all indexes
            // and use 0 as a sentinel value
            set._indexes[value] = set._values.length;
            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function _remove(Set storage set, bytes32 value) private returns (bool) {
        // We read and store the value's index to prevent multiple reads from the same storage slot
        uint256 valueIndex = set._indexes[value];

        if (valueIndex != 0) { // Equivalent to contains(set, value)
            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in
            // the array, and then remove the last element (sometimes called as 'swap and pop').
            // This modifies the order of the array, as noted in {at}.

            uint256 toDeleteIndex = valueIndex - 1;
            uint256 lastIndex = set._values.length - 1;

            // When the value to delete is the last one, the swap operation is unnecessary. However, since this occurs
            // so rarely, we still do the swap anyway to avoid the gas cost of adding an 'if' statement.

            bytes32 lastvalue = set._values[lastIndex];

            // Move the last value to the index where the value to delete is
            set._values[toDeleteIndex] = lastvalue;
            // Update the index for the moved value
            set._indexes[lastvalue] = toDeleteIndex + 1; // All indexes are 1-based

            // Delete the slot where the moved value was stored
            set._values.pop();

            // Delete the index for the deleted slot
            delete set._indexes[value];

            return true;
        } else {
            return false;
        }
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function _contains(Set storage set, bytes32 value) private view returns (bool) {
        return set._indexes[value] != 0;
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function _length(Set storage set) private view returns (uint256) {
        return set._values.length;
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function _at(Set storage set, uint256 index) private view returns (bytes32) {
        require(set._values.length > index, "EnumerableSet: index out of bounds");
        return set._values[index];
    }

    // Bytes32Set

    struct Bytes32Set {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _add(set._inner, value);
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {
        return _remove(set._inner, value);
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {
        return _contains(set._inner, value);
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(Bytes32Set storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {
        return _at(set._inner, index);
    }

    // AddressSet

    struct AddressSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(AddressSet storage set, address value) internal returns (bool) {
        return _add(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(AddressSet storage set, address value) internal returns (bool) {
        return _remove(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(AddressSet storage set, address value) internal view returns (bool) {
        return _contains(set._inner, bytes32(uint256(value)));
    }

    /**
     * @dev Returns the number of values in the set. O(1).
     */
    function length(AddressSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(AddressSet storage set, uint256 index) internal view returns (address) {
        return address(uint256(_at(set._inner, index)));
    }


    // UintSet

    struct UintSet {
        Set _inner;
    }

    /**
     * @dev Add a value to a set. O(1).
     *
     * Returns true if the value was added to the set, that is if it was not
     * already present.
     */
    function add(UintSet storage set, uint256 value) internal returns (bool) {
        return _add(set._inner, bytes32(value));
    }

    /**
     * @dev Removes a value from a set. O(1).
     *
     * Returns true if the value was removed from the set, that is if it was
     * present.
     */
    function remove(UintSet storage set, uint256 value) internal returns (bool) {
        return _remove(set._inner, bytes32(value));
    }

    /**
     * @dev Returns true if the value is in the set. O(1).
     */
    function contains(UintSet storage set, uint256 value) internal view returns (bool) {
        return _contains(set._inner, bytes32(value));
    }

    /**
     * @dev Returns the number of values on the set. O(1).
     */
    function length(UintSet storage set) internal view returns (uint256) {
        return _length(set._inner);
    }

   /**
    * @dev Returns the value stored at position `index` in the set. O(1).
    *
    * Note that there are no guarantees on the ordering of values inside the
    * array, and it may change when more values are added or removed.
    *
    * Requirements:
    *
    * - `index` must be strictly less than {length}.
    */
    function at(UintSet storage set, uint256 index) internal view returns (uint256) {
        return uint256(_at(set._inner, index));
    }
}

File 10 of 13 : Context.sol
// SPDX-License-Identifier: MIT

pragma solidity >=0.6.0 <0.8.0;

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

    function _msgData() internal view virtual returns (bytes memory) {
        this; // silence state mutability warning without generating bytecode - see https://github.com/ethereum/solidity/issues/2691
        return msg.data;
    }
}

File 11 of 13 : BytesLib.sol
// SPDX-License-Identifier: Unlicense
/*
 * @title Solidity Bytes Arrays Utils
 * @author Gonçalo Sá <[email protected]>
 *
 * @dev Bytes tightly packed arrays utility library for ethereum contracts written in Solidity.
 *      The library lets you concatenate, slice and type cast bytes arrays both in memory and storage.
 */
pragma solidity ^0.7.0;

library BytesLib {
    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 concatStorage(bytes storage _preBytes, bytes memory _postBytes) internal {
        assembly {
            // Read the first 32 bytes of _preBytes storage, which is the length
            // of the array. (We don't need to use the offset into the slot
            // because arrays use the entire slot.)
            let fslot := sload(_preBytes.slot)
            // Arrays of 31 bytes or less have an even value in their slot,
            // while longer arrays have an odd value. The actual length is
            // the slot divided by two for odd values, and the lowest order
            // byte divided by two for even values.
            // If the slot is even, bitwise and the slot with 255 and divide by
            // two to get the length. If the slot is odd, bitwise and the slot
            // with -1 and divide by two.
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)
            let newlength := add(slength, mlength)
            // slength can contain both the length and contents of the array
            // if length < 32 bytes so let's prepare for that
            // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
            switch add(lt(slength, 32), lt(newlength, 32))
            case 2 {
                // Since the new array still fits in the slot, we just need to
                // update the contents of the slot.
                // uint256(bytes_storage) = uint256(bytes_storage) + uint256(bytes_memory) + new_length
                sstore(
                    _preBytes.slot,
                    // all the modifications to the slot are inside this
                    // next block
                    add(
                        // we can just add to the slot contents because the
                        // bytes we want to change are the LSBs
                        fslot,
                        add(
                            mul(
                                div(
                                    // load the bytes from memory
                                    mload(add(_postBytes, 0x20)),
                                    // zero all bytes to the right
                                    exp(0x100, sub(32, mlength))
                                ),
                                // and now shift left the number of bytes to
                                // leave space for the length in the slot
                                exp(0x100, sub(32, newlength))
                            ),
                            // increase length by the double of the memory
                            // bytes length
                            mul(mlength, 2)
                        )
                    )
                )
            }
            case 1 {
                // The stored value fits in the slot, but the combined value
                // will exceed it.
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // The contents of the _postBytes array start 32 bytes into
                // the structure. Our first read should obtain the `submod`
                // bytes that can fit into the unused space in the last word
                // of the stored array. To get this, we read 32 bytes starting
                // from `submod`, so the data we read overlaps with the array
                // contents by `submod` bytes. Masking the lowest-order
                // `submod` bytes allows us to add that value directly to the
                // stored value.

                let submod := sub(32, slength)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(
                    sc,
                    add(
                        and(
                            fslot,
                            0xffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff00
                        ),
                        and(mload(mc), mask)
                    )
                )

                for {
                    mc := add(mc, 0x20)
                    sc := add(sc, 1)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
            default {
                // get the keccak hash to get the contents of the array
                mstore(0x0, _preBytes.slot)
                // Start copying to the last used word of the stored array.
                let sc := add(keccak256(0x0, 0x20), div(slength, 32))

                // save new length
                sstore(_preBytes.slot, add(mul(newlength, 2), 1))

                // Copy over the first `submod` bytes of the new data as in
                // case 1 above.
                let slengthmod := mod(slength, 32)
                let mlengthmod := mod(mlength, 32)
                let submod := sub(32, slengthmod)
                let mc := add(_postBytes, submod)
                let end := add(_postBytes, mlength)
                let mask := sub(exp(0x100, submod), 1)

                sstore(sc, add(sload(sc), and(mload(mc), mask)))

                for {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } lt(mc, end) {
                    sc := add(sc, 1)
                    mc := add(mc, 0x20)
                } {
                    sstore(sc, mload(mc))
                }

                mask := exp(0x100, sub(mc, end))

                sstore(sc, mul(div(mload(mc), mask), mask))
            }
        }
    }

    function slice(
        bytes memory _bytes,
        uint256 _start,
        uint256 _length
    )
        internal
        pure
        returns (bytes memory)
    {
        require(_bytes.length >= (_start + _length), "Read out of bounds");

        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, uint256 _start) internal pure returns (address) {
        require(_bytes.length >= (_start + 20), "Read out of bounds");
        address tempAddress;

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

        return tempAddress;
    }

    function toUint8(bytes memory _bytes, uint256 _start) internal pure returns (uint8) {
        require(_bytes.length >= (_start + 1), "Read out of bounds");
        uint8 tempUint;

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

        return tempUint;
    }

    function toUint16(bytes memory _bytes, uint256 _start) internal pure returns (uint16) {
        require(_bytes.length >= (_start + 2), "Read out of bounds");
        uint16 tempUint;

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

        return tempUint;
    }

    function toUint32(bytes memory _bytes, uint256 _start) internal pure returns (uint32) {
        require(_bytes.length >= (_start + 4), "Read out of bounds");
        uint32 tempUint;

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

        return tempUint;
    }

    function toUint64(bytes memory _bytes, uint256 _start) internal pure returns (uint64) {
        require(_bytes.length >= (_start + 8), "Read out of bounds");
        uint64 tempUint;

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

        return tempUint;
    }

    function toUint96(bytes memory _bytes, uint256 _start) internal pure returns (uint96) {
        require(_bytes.length >= (_start + 12), "Read out of bounds");
        uint96 tempUint;

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

        return tempUint;
    }

    function toUint128(bytes memory _bytes, uint256 _start) internal pure returns (uint128) {
        require(_bytes.length >= (_start + 16), "Read out of bounds");
        uint128 tempUint;

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

        return tempUint;
    }

    function toUint256(bytes memory _bytes, uint256 _start) internal pure returns (uint256) {
        require(_bytes.length >= (_start + 32), "Read out of bounds");
        uint256 tempUint;

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

        return tempUint;
    }

    function toBytes32(bytes memory _bytes, uint256 _start) internal pure returns (bytes32) {
        require(_bytes.length >= (_start + 32), "Read out of bounds");
        bytes32 tempBytes32;

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

        return tempBytes32;
    }

    function equal(bytes memory _preBytes, bytes memory _postBytes) internal pure returns (bool) {
        bool success = true;

        assembly {
            let length := mload(_preBytes)

            // if lengths don't match the arrays are not equal
            switch eq(length, mload(_postBytes))
            case 1 {
                // cb is a circuit breaker in the for loop since there's
                //  no said feature for inline assembly loops
                // cb = 1 - don't breaker
                // cb = 0 - break
                let cb := 1

                let mc := add(_preBytes, 0x20)
                let end := add(mc, length)

                for {
                    let cc := add(_postBytes, 0x20)
                // the next line is the loop condition:
                // while(uint256(mc < end) + cb == 2)
                } eq(add(lt(mc, end), cb), 2) {
                    mc := add(mc, 0x20)
                    cc := add(cc, 0x20)
                } {
                    // if any of these checks fails then arrays are not equal
                    if iszero(eq(mload(mc), mload(cc))) {
                        // unsuccess:
                        success := 0
                        cb := 0
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }

    function equalStorage(
        bytes storage _preBytes,
        bytes memory _postBytes
    )
        internal
        view
        returns (bool)
    {
        bool success = true;

        assembly {
            // we know _preBytes_offset is 0
            let fslot := sload(_preBytes.slot)
            // Decode the length of the stored array like in concatStorage().
            let slength := div(and(fslot, sub(mul(0x100, iszero(and(fslot, 1))), 1)), 2)
            let mlength := mload(_postBytes)

            // if lengths don't match the arrays are not equal
            switch eq(slength, mlength)
            case 1 {
                // slength can contain both the length and contents of the array
                // if length < 32 bytes so let's prepare for that
                // v. http://solidity.readthedocs.io/en/latest/miscellaneous.html#layout-of-state-variables-in-storage
                if iszero(iszero(slength)) {
                    switch lt(slength, 32)
                    case 1 {
                        // blank the last byte which is the length
                        fslot := mul(div(fslot, 0x100), 0x100)

                        if iszero(eq(fslot, mload(add(_postBytes, 0x20)))) {
                            // unsuccess:
                            success := 0
                        }
                    }
                    default {
                        // cb is a circuit breaker in the for loop since there's
                        //  no said feature for inline assembly loops
                        // cb = 1 - don't breaker
                        // cb = 0 - break
                        let cb := 1

                        // get the keccak hash to get the contents of the array
                        mstore(0x0, _preBytes.slot)
                        let sc := keccak256(0x0, 0x20)

                        let mc := add(_postBytes, 0x20)
                        let end := add(mc, mlength)

                        // the next line is the loop condition:
                        // while(uint256(mc < end) + cb == 2)
                        for {} eq(add(lt(mc, end), cb), 2) {
                            sc := add(sc, 1)
                            mc := add(mc, 0x20)
                        } {
                            if iszero(eq(sload(sc), mload(mc))) {
                                // unsuccess:
                                success := 0
                                cb := 0
                            }
                        }
                    }
                }
            }
            default {
                // unsuccess:
                success := 0
            }
        }

        return success;
    }
}

File 12 of 13 : CalldataEditor.sol
// SPDX-License-Identifier: MIT
pragma solidity ^0.7.0;

import "./BytesLib.sol";

abstract contract CalldataEditor {
    using BytesLib for bytes;

    /// @notice Returns uint from chunk of the bytecode
    /// @param data the compiled bytecode for the series of function calls
    /// @param location the current 'cursor' location within the bytecode
    /// @return result uint
    function uint256At(bytes memory data, uint256 location) pure internal returns (uint256 result) {
        assembly {
            result := mload(add(data, add(0x20, location)))
        }
    }

    /// @notice Returns address from chunk of the bytecode
    /// @param data the compiled bytecode for the series of function calls
    /// @param location the current 'cursor' location within the bytecode
    /// @return result address
    function addressAt(bytes memory data, uint256 location) pure internal returns (address result) {
        uint256 word = uint256At(data, location);
        assembly {
            result := div(and(word, 0xffffffffffffffffffffffffffffffffffffffff000000000000000000000000),
                          0x1000000000000000000000000)
        }
    }

    /// @notice Returns the start of the calldata within a chunk of the bytecode
    /// @param data the compiled bytecode for the series of function calls
    /// @param location the current 'cursor' location within the bytecode
    /// @return result pointer to start of calldata
    function locationOf(bytes memory data, uint256 location) pure internal returns (uint256 result) {
        assembly {
            result := add(data, add(0x20, location))
        }
    }
    
    /// @notice Replace the bytes at the index location in original with new bytes
    /// @param original original bytes
    /// @param newBytes new bytes to replace in original
    /// @param location the index within the original bytes where to make the replacement
    function replaceDataAt(bytes memory original, bytes memory newBytes, uint256 location) pure internal {
        assembly {
            mstore(add(add(original, location), 0x20), mload(add(newBytes, 0x20)))
        }
    }

    /// @dev Get the revert message from a call
    /// @notice This is needed in order to get the human-readable revert message from a call
    /// @param res Response of the call
    /// @return Revert message string
    function getRevertMsg(bytes memory res) internal pure returns (string memory) {
        // If the res length is less than 68, then the transaction failed silently (without a revert message)
        if (res.length < 68) return 'Call failed for unknown reason';
        bytes memory revertData = res.slice(4, res.length - 4); // Remove the selector which is the first 4 bytes
        return abi.decode(revertData, (string)); // All that remains is the revert string
    }
}

File 13 of 13 : ReentrancyGuard.sol
// SPDX-License-Identifier: MIT

pragma solidity ^0.7.0;

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

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

    uint256 private _status;

    constructor () {
        _status = _NOT_ENTERED;
    }

    /**
     * @dev Prevents a contract from calling itself, directly or indirectly.
     * Calling a `nonReentrant` function from another `nonReentrant`
     * function is not supported. It is possible to prevent this from happening
     * by making the `nonReentrant` function external, and make it call a
     * `private` function that does the actual work.
     */
    modifier nonReentrant() {
        // On the first call to nonReentrant, _notEntered will be true
        require(_status != _ENTERED, "ReentrancyGuard: reentrant call");

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

        _;

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

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

Contract Security Audit

Contract ABI

[{"inputs":[{"internalType":"uint8","name":"_version","type":"uint8"},{"internalType":"address","name":"_queryEngine","type":"address"},{"internalType":"address","name":"_roleManager","type":"address"},{"internalType":"address","name":"_lpManager","type":"address"},{"internalType":"address","name":"_withdrawer","type":"address"},{"internalType":"address","name":"_trader","type":"address"},{"internalType":"address","name":"_supplier","type":"address"},{"internalType":"uint256","name":"_initialMaxLiquidity","type":"uint256"},{"internalType":"address[]","name":"_lpWhitelist","type":"address[]"}],"stateMutability":"nonpayable","type":"constructor"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LiquidityProvided","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"address","name":"provider","type":"address"},{"indexed":false,"internalType":"uint256","name":"amount","type":"uint256"}],"name":"LiquidityRemoved","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"address","name":"asset","type":"address"},{"indexed":true,"internalType":"uint256","name":"newAmount","type":"uint256"},{"indexed":false,"internalType":"uint256","name":"oldAmount","type":"uint256"}],"name":"MaxLiquidityUpdated","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"previousAdminRole","type":"bytes32"},{"indexed":true,"internalType":"bytes32","name":"newAdminRole","type":"bytes32"}],"name":"RoleAdminChanged","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleGranted","type":"event"},{"anonymous":false,"inputs":[{"indexed":true,"internalType":"bytes32","name":"role","type":"bytes32"},{"indexed":true,"internalType":"address","name":"account","type":"address"},{"indexed":true,"internalType":"address","name":"sender","type":"address"}],"name":"RoleRevoked","type":"event"},{"stateMutability":"payable","type":"fallback"},{"inputs":[],"name":"APPROVER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"DEFAULT_ADMIN_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MANAGE_LP_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"MAX_LIQUIDITY","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"TRADER_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WHITELISTED_LP_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"WITHDRAW_ROLE","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"script","type":"bytes"},{"internalType":"uint256[]","name":"inputLocations","type":"uint256[]"}],"name":"estimateQueryCost","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleAdmin","outputs":[{"internalType":"bytes32","name":"","type":"bytes32"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"uint256","name":"index","type":"uint256"}],"name":"getRoleMember","outputs":[{"internalType":"address","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"}],"name":"getRoleMemberCount","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"grantRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"hasRole","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"isApprover","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"isLPManager","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"isTrader","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"isWhitelistedLP","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"addressToCheck","type":"address"}],"name":"isWithdrawer","outputs":[{"internalType":"bool","name":"","type":"bool"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"address","name":"","type":"address"}],"name":"lpBalances","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256","name":"ethValue","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256","name":"ethValue","type":"uint256"},{"internalType":"uint256","name":"minTimestamp","type":"uint256"},{"internalType":"uint256","name":"maxTimestamp","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"queryScript","type":"bytes"},{"internalType":"uint256[]","name":"queryInputLocations","type":"uint256[]"},{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256[]","name":"executeInputLocations","type":"uint256[]"},{"internalType":"uint256","name":"targetPrice","type":"uint256"},{"internalType":"uint256","name":"ethValue","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"queryScript","type":"bytes"},{"internalType":"uint256[]","name":"queryInputLocations","type":"uint256[]"},{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256[]","name":"executeInputLocations","type":"uint256[]"},{"internalType":"uint256","name":"targetPrice","type":"uint256"},{"internalType":"uint256","name":"ethValue","type":"uint256"},{"internalType":"uint256","name":"minTimestamp","type":"uint256"},{"internalType":"uint256","name":"maxTimestamp","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256","name":"ethValue","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes","name":"queryScript","type":"bytes"},{"internalType":"uint256[]","name":"queryInputLocations","type":"uint256[]"},{"internalType":"bytes","name":"executeScript","type":"bytes"},{"internalType":"uint256[]","name":"executeInputLocations","type":"uint256[]"},{"internalType":"uint256","name":"targetPrice","type":"uint256"},{"internalType":"uint256","name":"ethValue","type":"uint256"},{"internalType":"uint256","name":"blockDeadline","type":"uint256"}],"name":"makeTrade","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"provideETHLiquidity","outputs":[],"stateMutability":"payable","type":"function"},{"inputs":[],"name":"queryEngine","outputs":[{"internalType":"contract IQueryEngine","name":"","type":"address"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"removeETHLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"renounceRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokens","type":"address[]"},{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"rescueTokens","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"bytes32","name":"role","type":"bytes32"},{"internalType":"address","name":"account","type":"address"}],"name":"revokeRole","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"uint256","name":"newMax","type":"uint256"}],"name":"setMaxETHLiquidity","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokensToApprove","type":"address[]"},{"internalType":"uint256[]","name":"approvalAmounts","type":"uint256[]"},{"internalType":"address","name":"spender","type":"address"}],"name":"tokenAllow","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[{"internalType":"address[]","name":"tokensToApprove","type":"address[]"},{"internalType":"address","name":"spender","type":"address"}],"name":"tokenAllowAll","outputs":[],"stateMutability":"nonpayable","type":"function"},{"inputs":[],"name":"totalLiquidity","outputs":[{"internalType":"uint256","name":"","type":"uint256"}],"stateMutability":"view","type":"function"},{"inputs":[],"name":"version","outputs":[{"internalType":"uint8","name":"","type":"uint8"}],"stateMutability":"view","type":"function"},{"inputs":[{"internalType":"uint256","name":"amount","type":"uint256"}],"name":"withdrawEth","outputs":[],"stateMutability":"nonpayable","type":"function"},{"stateMutability":"payable","type":"receive"}]

Deployed Bytecode

0x60806040526004361061026e5760003560e01c806376e821cf11610153578063c311d049116100cb578063e02023a11161007f578063ec38857611610064578063ec38857614610679578063ecd1878f14610699578063f0a56fc8146106b957610275565b8063e02023a114610644578063e7abbb221461065957610275565b8063cc6febdf116100b0578063cc6febdf146105e4578063d547741f14610604578063d99125ee1461062457610275565b8063c311d049146105a4578063ca15c873146105c457610275565b806391d1485411610122578063a217fddf11610107578063a217fddf14610567578063ac19e8981461057c578063c2d4f8c01461058457610275565b806391d148541461053257806397ff5fb61461055257610275565b806376e821cf146104b057806379f645f0146104c55780639004e5c5146104e55780639010d07c1461050557610275565b806341650279116101e657806366f4deca116101b55780636880608f1161019a5780636880608f1461045b5780636d218e481461047b578063717f8df01461049b57610275565b806366f4deca1461041b57806368285acd1461043b57610275565b806341650279146103a45780634245962b146103c4578063509f1fc1146103d957806354fd4d50146103f957610275565b8063248a9ca31161023d57806336568abe1161022257806336568abe146103375780633dee3601146103575780634039ad0d1461037757610275565b8063248a9ca3146102f75780632f2ff15d1461031757610275565b80630b65092d14610277578063148e250d146102ad57806315770f92146102c257806318916513146102d757610275565b3661027557005b005b34801561028357600080fd5b50610297610292366004613784565b6106ce565b6040516102a49190613d97565b60405180910390f35b3480156102b957600080fd5b506102976106e0565b3480156102ce57600080fd5b506102976106e6565b3480156102e357600080fd5b506102756102f236600461379e565b6106ec565b34801561030357600080fd5b506102976103123660046138d0565b610922565b34801561032357600080fd5b506102756103323660046138e8565b61093a565b34801561034357600080fd5b506102756103523660046138e8565b6109a1565b34801561036357600080fd5b506102756103723660046138d0565b610a1c565b34801561038357600080fd5b50610397610392366004613784565b610b94565b6040516102a49190613d8c565b3480156103b057600080fd5b506102756103bf366004613c48565b610bc6565b3480156103d057600080fd5b50610297610d5f565b3480156103e557600080fd5b506102756103f4366004613cd7565b610d83565b34801561040557600080fd5b5061040e610fcc565b6040516102a49190614158565b34801561042757600080fd5b50610275610436366004613813565b610fed565b34801561044757600080fd5b506102756104563660046138d0565b611157565b34801561046757600080fd5b506102756104763660046139ff565b6111f4565b34801561048757600080fd5b50610397610496366004613784565b611632565b3480156104a757600080fd5b5061029761165e565b3480156104bc57600080fd5b50610297611682565b3480156104d157600080fd5b506102756104e036600461385f565b6116a6565b3480156104f157600080fd5b50610397610500366004613784565b611829565b34801561051157600080fd5b5061052561052036600461390a565b611855565b6040516102a49190613d44565b34801561053e57600080fd5b5061039761054d3660046138e8565b611874565b34801561055e57600080fd5b5061052561188c565b34801561057357600080fd5b506102976118a8565b6102756118ad565b34801561059057600080fd5b5061039761059f366004613784565b6119cc565b3480156105b057600080fd5b506102756105bf3660046138d0565b6119f8565b3480156105d057600080fd5b506102976105df3660046138d0565b611b12565b3480156105f057600080fd5b506102756105ff36600461399e565b611b29565b34801561061057600080fd5b5061027561061f3660046138e8565b611bd5565b34801561063057600080fd5b5061027561063f366004613b7c565b611c2e565b34801561065057600080fd5b50610297612123565b34801561066557600080fd5b50610275610674366004613c8b565b612147565b34801561068557600080fd5b50610275610694366004613ab9565b612338565b3480156106a557600080fd5b506103976106b4366004613784565b6127d0565b3480156106c557600080fd5b506102976127fc565b60056020526000908152604090205481565b60035481565b60045481565b6107167f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec33611874565b61073b5760405162461bcd60e51b815260040161073290613f54565b60405180910390fd5b60005b8281101561091c57600084848381811061075457fe5b90506020020160208101906107699190613784565b90506000808273ffffffffffffffffffffffffffffffffffffffff166370a08231306040518263ffffffff1660e01b81526004016107a79190613d44565b60206040518083038186803b1580156107bf57600080fd5b505afa1580156107d3573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906107f79190613d29565b905060008373ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30336040518363ffffffff1660e01b8152600401610836929190613d65565b60206040518083038186803b15801561084e57600080fd5b505afa158015610862573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906108869190613d29565b9050856108a6578082111561089d578092506108a1565b8192505b6108ea565b858210156108c65760405162461bcd60e51b81526004016107329061401f565b858110156108e65760405162461bcd60e51b815260040161073290613f1d565b8592505b61090c73ffffffffffffffffffffffffffffffffffffffff8516303386612842565b50506001909201915061073e9050565b50505050565b6000818152600160205260409020600201545b919050565b6000828152600160205260409020600201546109589061054d6128d7565b6109935760405162461bcd60e51b815260040180806020018281038252602f815260200180614219602f913960400191505060405180910390fd5b61099d82826128db565b5050565b6109a96128d7565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff1614610a125760405162461bcd60e51b815260040180806020018281038252602f8152602001806142fe602f913960400191505060405180910390fd5b61099d828261295e565b33600090815260056020526040902054811115610a4b5760405162461bcd60e51b8152600401610732906140c4565b600454600090610a5b90836129e1565b1015610a795760405162461bcd60e51b81526004016107329061408d565b6000610a8547836129e1565b1015610aa35760405162461bcd60e51b815260040161073290614121565b33600090815260056020526040902054610abd90826129e1565b33600090815260056020526040902055600454610ada90826129e1565b60045560405160009033908390610af090613d41565b60006040518083038185875af1925050503d8060008114610b2d576040519150601f19603f3d011682016040523d82523d6000602084013e610b32565b606091505b5050905080610b535760405162461bcd60e51b815260040161073290613f8b565b60405133906000907f983e86fda8e7b1e2eae380201830eaf1cac55772e8e39583da349865e817886390610b88908690613d97565b60405180910390a35050565b6000610bc07ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194183611874565b92915050565b610bf07ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b610c41576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b60026000541415610c99576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055804781811015610cf5576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b610cff8484612a23565b80471015610d54576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b505060016000555050565b7f408a36151f841709116a4e8aca4e0202874f7f54687dcb863b1ea4672dc9d8cf81565b610dad7ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b610dfe576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b60026000541415610e56576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055818142811015610eb2576040805162461bcd60e51b815260206004820152600e60248201527f747261646520746f6f206c617465000000000000000000000000000000000000604482015290519081900360640190fd5b42821115610f07576040805162461bcd60e51b815260206004820152600f60248201527f747261646520746f6f206561726c790000000000000000000000000000000000604482015290519081900360640190fd5b844781811015610f5e576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b610f688888612a23565b80471015610fbd576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b50506001600055505050505050565b60025474010000000000000000000000000000000000000000900460ff1681565b6110177f408a36151f841709116a4e8aca4e0202874f7f54687dcb863b1ea4672dc9d8cf33611874565b6110335760405162461bcd60e51b815260040161073290614056565b60005b825181101561115257600083828151811061104d57fe5b602002602001015190507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8173ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30866040518363ffffffff1660e01b81526004016110b3929190613d65565b60206040518083038186803b1580156110cb57600080fd5b505afa1580156110df573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906111039190613d29565b146111495761114973ffffffffffffffffffffffffffffffffffffffff8216847fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff612a92565b50600101611036565b505050565b6111817fa381348eb3fe7f232f3078689dd9188d0bc370b23350159f64231117527caec733611874565b61119d5760405162461bcd60e51b815260040161073290613e78565b80600073ffffffffffffffffffffffffffffffffffffffff167fb2c6cf9c77391977298388e9125711ceb6bd1ddc9e8a8da1d2af054316cbc8536003546040516111e79190613d97565b60405180910390a3600355565b61121e7ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b61126f576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b600260005414156112c7576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055804781811015611323576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b600254604080517fa363a0f3000000000000000000000000000000000000000000000000000000008152600481019182528a5160448201528a5160609373ffffffffffffffffffffffffffffffffffffffff169263a363a0f3928d928d92918291602482019160640190602087019080838360005b838110156113b0578181015183820152602001611398565b50505050905090810190601f1680156113dd5780820380516001836020036101000a031916815260200191505b508381038252845181528451602091820191808701910280838360005b838110156114125781810151838201526020016113fa565b5050505090500194505050505060006040518083038186803b15801561143757600080fd5b505afa15801561144b573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561147457600080fd5b810190808051604051939291908464010000000082111561149457600080fd5b9083019060208201858111156114a957600080fd5b82516401000000008111828201881017156114c357600080fd5b82525081516020918201929091019080838360005b838110156114f05781810151838201526020016114d8565b50505050905090810190601f16801561151d5780820380516001836020036101000a031916815260200191505b5060405250505090508461153e602083510383612c0690919063ffffffff16565b1015611591576040805162461bcd60e51b815260206004820152600e60248201527f4e6f742070726f66697461626c65000000000000000000000000000000000000604482015290519081900360640190fd5b60005b86518110156115d1576115c9886115b084602080860290612c6a565b8984815181106115bc57fe5b6020026020010151612d32565b600101611594565b506115dc8785612a23565b5080471015610fbd576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b6000610bc07f408a36151f841709116a4e8aca4e0202874f7f54687dcb863b1ea4672dc9d8cf83611874565b7fa381348eb3fe7f232f3078689dd9188d0bc370b23350159f64231117527caec781565b7fea728681f55b7658af02b019305006d1b2faefced46ff12facedd896da3c3dc681565b6116d07f408a36151f841709116a4e8aca4e0202874f7f54687dcb863b1ea4672dc9d8cf33611874565b6116ec5760405162461bcd60e51b815260040161073290614056565b815183511461170d5760405162461bcd60e51b815260040161073290613eaf565b60005b835181101561091c57600084828151811061172757fe5b602002602001015190507fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff8173ffffffffffffffffffffffffffffffffffffffff1663dd62ed3e30866040518363ffffffff1660e01b815260040161178d929190613d65565b60206040518083038186803b1580156117a557600080fd5b505afa1580156117b9573d6000803e3d6000fd5b505050506040513d601f19601f820116820180604052508101906117dd9190613d29565b1461182057611820838584815181106117f257fe5b60200260200101518373ffffffffffffffffffffffffffffffffffffffff16612a929092919063ffffffff16565b50600101611710565b6000610bc07f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec83611874565b600082815260016020526040812061186d9083612d3e565b9392505050565b600082815260016020526040812061186d9083612d4a565b60025473ffffffffffffffffffffffffffffffffffffffff1681565b600081565b60006118d87fea728681f55b7658af02b019305006d1b2faefced46ff12facedd896da3c3dc6611b12565b1115611924576119087fea728681f55b7658af02b019305006d1b2faefced46ff12facedd896da3c3dc633611874565b6119245760405162461bcd60e51b815260040161073290613e1b565b6003546004546119349034612d6c565b11156119525760405162461bcd60e51b815260040161073290613ee6565b60045461195f9034612d6c565b6004553360009081526005602052604090205461197c9034612d6c565b336000818152600560205260408082209390935591519091907f05e7be2689d5d20fd06bc749aa0d767080c4216945cacf5249f739d5a561d48f906119c2903490613d97565b60405180910390a3565b6000610bc07fea728681f55b7658af02b019305006d1b2faefced46ff12facedd896da3c3dc683611874565b611a227f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec33611874565b611a3e5760405162461bcd60e51b815260040161073290613f54565b600080611a56600454476129e190919063ffffffff16565b905082611a6557809150611a89565b82811015611a855760405162461bcd60e51b815260040161073290613fc2565b8291505b60003373ffffffffffffffffffffffffffffffffffffffff1683604051611aaf90613d41565b60006040518083038185875af1925050503d8060008114611aec576040519150601f19603f3d011682016040523d82523d6000602084013e611af1565b606091505b505090508061091c5760405162461bcd60e51b815260040161073290613f8b565b6000818152600160205260408120610bc090612dc6565b6002546040517fa363a0f300000000000000000000000000000000000000000000000000000000815273ffffffffffffffffffffffffffffffffffffffff9091169063a363a0f390611b819085908590600401613da0565b60006040518083038186803b158015611b9957600080fd5b505afa158015611bad573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052611152919081019061392b565b600082815260016020526040902060020154611bf39061054d6128d7565b610a125760405162461bcd60e51b815260040180806020018281038252603081526020018061426e6030913960400191505060405180910390fd5b611c587ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b611ca9576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b60026000541415611d01576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b6002600055818142811015611d5d576040805162461bcd60e51b815260206004820152600e60248201527f747261646520746f6f206c617465000000000000000000000000000000000000604482015290519081900360640190fd5b42821115611db2576040805162461bcd60e51b815260206004820152600f60248201527f747261646520746f6f206561726c790000000000000000000000000000000000604482015290519081900360640190fd5b844781811015611e09576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b6060600260009054906101000a900473ffffffffffffffffffffffffffffffffffffffff1673ffffffffffffffffffffffffffffffffffffffff1663a363a0f38e8e6040518363ffffffff1660e01b8152600401808060200180602001838103835285818151815260200191508051906020019080838360005b83811015611e9b578181015183820152602001611e83565b50505050905090810190601f168015611ec85780820380516001836020036101000a031916815260200191505b508381038252845181528451602091820191808701910280838360005b83811015611efd578181015183820152602001611ee5565b5050505090500194505050505060006040518083038186803b158015611f2257600080fd5b505afa158015611f36573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f191682016040526020811015611f5f57600080fd5b8101908080516040519392919084640100000000821115611f7f57600080fd5b908301906020820185811115611f9457600080fd5b8251640100000000811182820188101715611fae57600080fd5b82525081516020918201929091019080838360005b83811015611fdb578181015183820152602001611fc3565b50505050905090810190601f1680156120085780820380516001836020036101000a031916815260200191505b50604052505050905088612029602083510383612c0690919063ffffffff16565b101561207c576040805162461bcd60e51b815260206004820152600e60248201527f4e6f742070726f66697461626c65000000000000000000000000000000000000604482015290519081900360640190fd5b60005b8a518110156120af576120a78c61209b84602080860290612c6a565b8d84815181106115bc57fe5b60010161207f565b506120ba8b89612a23565b5080471015612110576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b5050600160005550505050505050505050565b7f5d8e12c39142ff96d79d04d15d1ba1269e4fe57bb9d26f43523628b34ba108ec81565b6121717ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b6121c2576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b6002600054141561221a576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000558043811015612275576040805162461bcd60e51b815260206004820152600d60248201527f7472616465206578706972656400000000000000000000000000000000000000604482015290519081900360640190fd5b8247818110156122cc576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b6122d68686612a23565b8047101561232b576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b5050600160005550505050565b6123627ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194133611874565b6123b3576040805162461bcd60e51b815260206004820152601c60248201527f547261646572206d75737420686176652054524144455220726f6c6500000000604482015290519081900360640190fd5b6002600054141561240b576040805162461bcd60e51b815260206004820152601f60248201527f5265656e7472616e637947756172643a207265656e7472616e742063616c6c00604482015290519081900360640190fd5b60026000558043811015612466576040805162461bcd60e51b815260206004820152600d60248201527f7472616465206578706972656400000000000000000000000000000000000000604482015290519081900360640190fd5b8247818110156124bd576040805162461bcd60e51b815260206004820152601a60248201527f4e6f7420656e6f7567682045544820696e20636f6e7472616374000000000000604482015290519081900360640190fd5b600254604080517fa363a0f3000000000000000000000000000000000000000000000000000000008152600481019182528c5160448201528c5160609373ffffffffffffffffffffffffffffffffffffffff169263a363a0f3928f928f92918291602482019160640190602087019080838360005b8381101561254a578181015183820152602001612532565b50505050905090810190601f1680156125775780820380516001836020036101000a031916815260200191505b508381038252845181528451602091820191808701910280838360005b838110156125ac578181015183820152602001612594565b5050505090500194505050505060006040518083038186803b1580156125d157600080fd5b505afa1580156125e5573d6000803e3d6000fd5b505050506040513d6000823e601f3d908101601f19168201604052602081101561260e57600080fd5b810190808051604051939291908464010000000082111561262e57600080fd5b90830190602082018581111561264357600080fd5b825164010000000081118282018810171561265d57600080fd5b82525081516020918201929091019080838360005b8381101561268a578181015183820152602001612672565b50505050905090810190601f1680156126b75780820380516001836020036101000a031916815260200191505b506040525050509050866126d8602083510383612c0690919063ffffffff16565b101561272b576040805162461bcd60e51b815260206004820152600e60248201527f4e6f742070726f66697461626c65000000000000000000000000000000000000604482015290519081900360640190fd5b60005b885181101561275e576127568a61274a84602080860290612c6a565b8b84815181106115bc57fe5b60010161272e565b506127698987612a23565b50804710156127bf576040805162461bcd60e51b815260206004820152600b60248201527f6d697373696e6720455448000000000000000000000000000000000000000000604482015290519081900360640190fd5b505060016000555050505050505050565b6000610bc07fa381348eb3fe7f232f3078689dd9188d0bc370b23350159f64231117527caec783611874565b7ffacaf2747a7486cf5730e9265973fb54447d3ace6e7e4711f6360826b073194181565b600061186d8373ffffffffffffffffffffffffffffffffffffffff8416612dd1565b6040805173ffffffffffffffffffffffffffffffffffffffff80861660248301528416604482015260648082018490528251808303909101815260849091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f23b872dd0000000000000000000000000000000000000000000000000000000017905261091c908590612e1b565b3390565b60008281526001602052604090206128f39082612820565b1561099d576129006128d7565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837f2f8788117e7eff1d82e926ec794901d17c78024a50270940304540a733656f0d60405160405180910390a45050565b60008281526001602052604090206129769082612ed9565b1561099d576129836128d7565b73ffffffffffffffffffffffffffffffffffffffff168173ffffffffffffffffffffffffffffffffffffffff16837ff6391f5c32d9c69d2a47ea670b442974b53935d1edc7fd64eb21e047a839171b60405160405180910390a45050565b600061186d83836040518060400160405280601f81526020017f536166654d6174683a207375627472616374696f6e20756e646572666c6f7700815250612efb565b60005b8251811015611152576000612a3b8483612f92565b90506000612a4c8584601401612fda565b9050603483016060612a5f878385612c6a565b905084612a7657612a71848288612fe2565b612a82565b612a8284826000612fe2565b5050919091016034019050612a26565b801580612b3e5750604080517fdd62ed3e00000000000000000000000000000000000000000000000000000000815230600482015273ffffffffffffffffffffffffffffffffffffffff848116602483015291519185169163dd62ed3e91604480820192602092909190829003018186803b158015612b1057600080fd5b505afa158015612b24573d6000803e3d6000fd5b505050506040513d6020811015612b3a57600080fd5b5051155b612b795760405162461bcd60e51b81526004018080602001828103825260368152602001806142c86036913960400191505060405180910390fd5b6040805173ffffffffffffffffffffffffffffffffffffffff8416602482015260448082018490528251808303909101815260649091019091526020810180517bffffffffffffffffffffffffffffffffffffffffffffffffffffffff167f095ea7b300000000000000000000000000000000000000000000000000000000179052611152908490612e1b565b60008160200183511015612c61576040805162461bcd60e51b815260206004820152601260248201527f52656164206f7574206f6620626f756e64730000000000000000000000000000604482015290519081900360640190fd5b50016020015190565b606081830184511015612cc4576040805162461bcd60e51b815260206004820152601260248201527f52656164206f7574206f6620626f756e64730000000000000000000000000000604482015290519081900360640190fd5b606082158015612cdf57604051915060208201604052612d29565b6040519150601f8416801560200281840101858101878315602002848b0101015b81831015612d18578051835260209283019201612d00565b5050858452601f01601f1916604052505b50949350505050565b60209182015192010152565b600061186d83836131bf565b600061186d8373ffffffffffffffffffffffffffffffffffffffff8416613223565b60008282018381101561186d576040805162461bcd60e51b815260206004820152601b60248201527f536166654d6174683a206164646974696f6e206f766572666c6f770000000000604482015290519081900360640190fd5b6000610bc08261323b565b6000612ddd8383613223565b612e1357508154600181810184556000848152602080822090930184905584548482528286019093526040902091909155610bc0565b506000610bc0565b6060612e7d826040518060400160405280602081526020017f5361666545524332303a206c6f772d6c6576656c2063616c6c206661696c65648152508573ffffffffffffffffffffffffffffffffffffffff1661323f9092919063ffffffff16565b80519091501561115257808060200190516020811015612e9c57600080fd5b50516111525760405162461bcd60e51b815260040180806020018281038252602a81526020018061429e602a913960400191505060405180910390fd5b600061186d8373ffffffffffffffffffffffffffffffffffffffff8416613256565b60008184841115612f8a5760405162461bcd60e51b81526004018080602001828103825283818151815260200191508051906020019080838360005b83811015612f4f578181015183820152602001612f37565b50505050905090810190601f168015612f7c5780820380516001836020036101000a031916815260200191505b509250505060405180910390fd5b505050900390565b600080612f9f8484612fda565b6c010000000000000000000000007fffffffffffffffffffffffffffffffffffffffff00000000000000000000000090911604949350505050565b016020015190565b600060608483156130a7578073ffffffffffffffffffffffffffffffffffffffff1684866040518082805190602001908083835b602083106130355780518252601f199092019160209182019101613016565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d8060008114613097576040519150601f19603f3d011682016040523d82523d6000602084013e61309c565b606091505b50909350915061315c565b8073ffffffffffffffffffffffffffffffffffffffff16856040518082805190602001908083835b602083106130ee5780518252601f1990920191602091820191016130cf565b6001836020036101000a0380198251168184511680821785525050505050509050019150506000604051808303816000865af19150503d8060008114613150576040519150601f19603f3d011682016040523d82523d6000602084013e613155565b606091505b5090935091505b826131b757606061316c8361333a565b90508060405162461bcd60e51b815260040180806020018281038252838181518152602001915080519060200190808383600083811015612f4f578181015183820152602001612f37565b505050505050565b815460009082106132015760405162461bcd60e51b81526004018080602001828103825260228152602001806141f76022913960400191505060405180910390fd5b82600001828154811061321057fe5b9060005260206000200154905092915050565b60009081526001919091016020526040902054151590565b5490565b606061324e848460008561346a565b949350505050565b600081815260018301602052604081205480156133305783547fffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffffff80830191908101906000908790839081106132a757fe5b90600052602060002001549050808760000184815481106132c457fe5b6000918252602080832090910192909255828152600189810190925260409020908401905586548790806132f457fe5b60019003818190600052602060002001600090559055866001016000878152602001908152602001600020600090556001945050505050610bc0565b6000915050610bc0565b6060604482511015613380575060408051808201909152601e81527f43616c6c206661696c656420666f7220756e6b6e6f776e20726561736f6e00006020820152610935565b606061339b60048085510385612c6a9092919063ffffffff16565b90508080602001905160208110156133b257600080fd5b81019080805160405193929190846401000000008211156133d257600080fd5b9083019060208201858111156133e757600080fd5b825164010000000081118282018810171561340157600080fd5b82525081516020918201929091019080838360005b8381101561342e578181015183820152602001613416565b50505050905090810190601f16801561345b5780820380516001836020036101000a031916815260200191505b50604052505050915050919050565b6060824710156134ab5760405162461bcd60e51b81526004018080602001828103825260268152602001806142486026913960400191505060405180910390fd5b6134b4856135d3565b613505576040805162461bcd60e51b815260206004820152601d60248201527f416464726573733a2063616c6c20746f206e6f6e2d636f6e7472616374000000604482015290519081900360640190fd5b600060608673ffffffffffffffffffffffffffffffffffffffff1685876040518082805190602001908083835b602083106135515780518252601f199092019160209182019101613532565b6001836020036101000a03801982511681845116808217855250505050505090500191505060006040518083038185875af1925050503d80600081146135b3576040519150601f19603f3d011682016040523d82523d6000602084013e6135b8565b606091505b50915091506135c88282866135d9565b979650505050505050565b3b151590565b606083156135e857508161186d565b8251156135f85782518084602001fd5b60405162461bcd60e51b8152602060048201818152845160248401528451859391928392604401919085019080838360008315612f4f578181015183820152602001612f37565b803573ffffffffffffffffffffffffffffffffffffffff8116811461093557600080fd5b600082601f830112613673578081fd5b81356136866136818261418a565b614166565b8181529150602080830190848101818402860182018710156136a757600080fd5b60005b848110156136cd576136bb8261363f565b845292820192908201906001016136aa565b505050505092915050565b600082601f8301126136e8578081fd5b81356136f66136818261418a565b81815291506020808301908481018184028601820187101561371757600080fd5b60005b848110156136cd5781358452928201929082019060010161371a565b600082601f830112613746578081fd5b8135613754613681826141a8565b915080825283602082850101111561376b57600080fd5b8060208401602084013760009082016020015292915050565b600060208284031215613795578081fd5b61186d8261363f565b6000806000604084860312156137b2578182fd5b833567ffffffffffffffff808211156137c9578384fd5b818601915086601f8301126137dc578384fd5b8135818111156137ea578485fd5b87602080830285010111156137fd578485fd5b6020928301989097509590910135949350505050565b60008060408385031215613825578182fd5b823567ffffffffffffffff81111561383b578283fd5b61384785828601613663565b9250506138566020840161363f565b90509250929050565b600080600060608486031215613873578283fd5b833567ffffffffffffffff8082111561388a578485fd5b61389687838801613663565b945060208601359150808211156138ab578384fd5b506138b8868287016136d8565b9250506138c76040850161363f565b90509250925092565b6000602082840312156138e1578081fd5b5035919050565b600080604083850312156138fa578182fd5b823591506138566020840161363f565b6000806040838503121561391c578182fd5b50508035926020909101359150565b60006020828403121561393c578081fd5b815167ffffffffffffffff811115613952578182fd5b8201601f81018413613962578182fd5b8051613970613681826141a8565b818152856020838501011115613984578384fd5b6139958260208301602086016141ca565b95945050505050565b600080604083850312156139b0578182fd5b823567ffffffffffffffff808211156139c7578384fd5b6139d386838701613736565b935060208501359150808211156139e8578283fd5b506139f5858286016136d8565b9150509250929050565b60008060008060008060c08789031215613a17578182fd5b863567ffffffffffffffff80821115613a2e578384fd5b613a3a8a838b01613736565b97506020890135915080821115613a4f578384fd5b613a5b8a838b016136d8565b96506040890135915080821115613a70578384fd5b613a7c8a838b01613736565b95506060890135915080821115613a91578384fd5b50613a9e89828a016136d8565b9350506080870135915060a087013590509295509295509295565b600080600080600080600060e0888a031215613ad3578081fd5b873567ffffffffffffffff80821115613aea578283fd5b613af68b838c01613736565b985060208a0135915080821115613b0b578283fd5b613b178b838c016136d8565b975060408a0135915080821115613b2c578283fd5b613b388b838c01613736565b965060608a0135915080821115613b4d578283fd5b50613b5a8a828b016136d8565b979a969950949760808101359660a0820135965060c090910135945092505050565b600080600080600080600080610100898b031215613b98578182fd5b883567ffffffffffffffff80821115613baf578384fd5b613bbb8c838d01613736565b995060208b0135915080821115613bd0578384fd5b613bdc8c838d016136d8565b985060408b0135915080821115613bf1578384fd5b613bfd8c838d01613736565b975060608b0135915080821115613c12578384fd5b50613c1f8b828c016136d8565b989b979a50959860808101359760a0820135975060c0820135965060e090910135945092505050565b60008060408385031215613c5a578182fd5b823567ffffffffffffffff811115613c70578283fd5b613c7c85828601613736565b95602094909401359450505050565b600080600060608486031215613c9f578081fd5b833567ffffffffffffffff811115613cb5578182fd5b613cc186828701613736565b9660208601359650604090950135949350505050565b60008060008060808587031215613cec578182fd5b843567ffffffffffffffff811115613d02578283fd5b613d0e87828801613736565b97602087013597506040870135966060013595509350505050565b600060208284031215613d3a578081fd5b5051919050565b90565b73ffffffffffffffffffffffffffffffffffffffff91909116815260200190565b73ffffffffffffffffffffffffffffffffffffffff92831681529116602082015260400190565b901515815260200190565b90815260200190565b60006040825283518060408401526020613dc082606086018389016141ca565b601f19601f83011684019150606082016060858403018286015280865180835260808501915083880194508592505b80831015613e0f5784518252938301936001929092019190830190613def565b50979650505050505050565b60208082526024908201527f43616c6c6572206d75737420686176652057484954454c49535445445f4c502060408201527f726f6c6500000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f43616c6c6572206d7573742068617665204d414e4147455f4c5020726f6c6500604082015260600190565b6020808252600f908201527f6e6f742073616d65206c656e6774680000000000000000000000000000000000604082015260600190565b6020808252601c908201527f616d6f756e742065786365656473206d6178206c697175696469747900000000604082015260600190565b60208082526018908201527f496e63726561736520746f6b656e20616c6c6f77616e63650000000000000000604082015260600190565b6020808252601e908201527f43616c6c6572206d757374206861766520574954484452415720726f6c650000604082015260600190565b60208082526016908201527f436f756c64206e6f742077697468647261772045544800000000000000000000604082015260600190565b60208082526023908201527f616d6f756e74206578636565647320776974686472617761626c652062616c6160408201527f6e63650000000000000000000000000000000000000000000000000000000000606082015260800190565b60208082526018908201527f436f6e74726163742062616c616e636520746f6f206c6f770000000000000000604082015260600190565b6020808252601e908201527f43616c6c6572206d757374206861766520415050524f56455220726f6c650000604082015260600190565b6020808252601e908201527f616d6f756e74206578636565647320746f74616c206c69717569646974790000604082015260600190565b60208082526021908201527f616d6f756e742065786365656473206c69717569646974792070726f7669646560408201527f6400000000000000000000000000000000000000000000000000000000000000606082015260800190565b6020808252601f908201527f616d6f756e74206578636565647320636f6e74726163742062616c616e636500604082015260600190565b60ff91909116815260200190565b60405181810167ffffffffffffffff8111828210171561418257fe5b604052919050565b600067ffffffffffffffff82111561419e57fe5b5060209081020190565b600067ffffffffffffffff8211156141bc57fe5b50601f01601f191660200190565b60005b838110156141e55781810151838201526020016141cd565b8381111561091c575050600091015256fe456e756d657261626c655365743a20696e646578206f7574206f6620626f756e6473416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f206772616e74416464726573733a20696e73756666696369656e742062616c616e636520666f722063616c6c416363657373436f6e74726f6c3a2073656e646572206d75737420626520616e2061646d696e20746f207265766f6b655361666545524332303a204552433230206f7065726174696f6e20646964206e6f7420737563636565645361666545524332303a20617070726f76652066726f6d206e6f6e2d7a65726f20746f206e6f6e2d7a65726f20616c6c6f77616e6365416363657373436f6e74726f6c3a2063616e206f6e6c792072656e6f756e636520726f6c657320666f722073656c66a2646970667358221220a1144a623c7ae673a1ba5231deafc9f7f1cbaa52df7b85ab835377bcd3f4d29d64736f6c63430007040033

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  ]
[ 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.