{
  "language": "Solidity",
  "sources": {
    "contracts/functions/FExec.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport {GelatoBytes} from \"../vendor/gelato/GelatoBytes.sol\";\n\n// solhint-disable private-vars-leading-underscore\n// solhint-disable func-visibility\n\nfunction _call(\n    address _add,\n    bytes memory _data,\n    uint256 _value,\n    bool _revertOnFailure,\n    string memory _tracingInfo\n) returns (bool success, bytes memory returnData) {\n    (success, returnData) = _add.call{value: _value}(_data);\n\n    if (!success && _revertOnFailure)\n        GelatoBytes.revertWithError(returnData, _tracingInfo);\n}\n\nfunction _delegateCall(\n    address _add,\n    bytes memory _data,\n    string memory _tracingInfo\n) returns (bool success, bytes memory returnData) {\n    (success, returnData) = _add.delegatecall(_data);\n\n    if (!success) GelatoBytes.revertWithError(returnData, _tracingInfo);\n}\n"
    },
    "contracts/vendor/gelato/GelatoBytes.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nlibrary GelatoBytes {\n    function calldataSliceSelector(bytes calldata _bytes)\n        internal\n        pure\n        returns (bytes4 selector)\n    {\n        selector =\n            _bytes[0] |\n            (bytes4(_bytes[1]) >> 8) |\n            (bytes4(_bytes[2]) >> 16) |\n            (bytes4(_bytes[3]) >> 24);\n    }\n\n    function memorySliceSelector(bytes memory _bytes)\n        internal\n        pure\n        returns (bytes4 selector)\n    {\n        selector =\n            _bytes[0] |\n            (bytes4(_bytes[1]) >> 8) |\n            (bytes4(_bytes[2]) >> 16) |\n            (bytes4(_bytes[3]) >> 24);\n    }\n\n    function revertWithError(bytes memory _bytes, string memory _tracingInfo)\n        internal\n        pure\n    {\n        // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err\n        if (_bytes.length % 32 == 4) {\n            bytes4 selector;\n            assembly {\n                selector := mload(add(0x20, _bytes))\n            }\n            if (selector == 0x08c379a0) {\n                // Function selector for Error(string)\n                assembly {\n                    _bytes := add(_bytes, 68)\n                }\n                revert(string(abi.encodePacked(_tracingInfo, string(_bytes))));\n            } else {\n                revert(\n                    string(abi.encodePacked(_tracingInfo, \"NoErrorSelector\"))\n                );\n            }\n        } else {\n            revert(\n                string(abi.encodePacked(_tracingInfo, \"UnexpectedReturndata\"))\n            );\n        }\n    }\n\n    function returnError(bytes memory _bytes, string memory _tracingInfo)\n        internal\n        pure\n        returns (string memory)\n    {\n        // 68: 32-location, 32-length, 4-ErrorSelector, UTF-8 err\n        if (_bytes.length % 32 == 4) {\n            bytes4 selector;\n            assembly {\n                selector := mload(add(0x20, _bytes))\n            }\n            if (selector == 0x08c379a0) {\n                // Function selector for Error(string)\n                assembly {\n                    _bytes := add(_bytes, 68)\n                }\n                return string(abi.encodePacked(_tracingInfo, string(_bytes)));\n            } else {\n                return\n                    string(abi.encodePacked(_tracingInfo, \"NoErrorSelector\"));\n            }\n        } else {\n            return\n                string(abi.encodePacked(_tracingInfo, \"UnexpectedReturndata\"));\n        }\n    }\n}\n"
    },
    "contracts/taskModules/Web3FunctionModule.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {TaskModuleBase} from \"./TaskModuleBase.sol\";\nimport {LibDataTypes} from \"../libraries/LibDataTypes.sol\";\nimport {_call} from \"../functions/FExec.sol\";\n\ncontract Web3FunctionModule is TaskModuleBase {\n    /**\n     * @notice Helper function to encode arguments for Web3FunctionModule.\n     *\n     * @param _web3FunctionHash IPFS hash of web3 function.\n     * @param _web3FunctionArgsHex Arguments to be passed into web3 function in hex.\n     */\n    function encodeModuleArg(\n        string memory _web3FunctionHash,\n        bytes calldata _web3FunctionArgsHex\n    ) external pure returns (bytes memory) {\n        return abi.encode(_web3FunctionHash, _web3FunctionArgsHex);\n    }\n}\n"
    },
    "contracts/taskModules/TaskModuleBase.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {OpsStorage} from \"../OpsStorage.sol\";\nimport {ITaskModule} from \"../interfaces/ITaskModule.sol\";\n\n// solhint-disable no-empty-blocks\nabstract contract TaskModuleBase is OpsStorage, ITaskModule {\n    ///@inheritdoc ITaskModule\n    function preCreateTask(address _taskCreator, address _execAddress)\n        external\n        virtual\n        override\n        returns (address, address)\n    {\n        return (_taskCreator, _execAddress);\n    }\n\n    ///@inheritdoc ITaskModule\n    function onCreateTask(\n        bytes32,\n        address,\n        address,\n        bytes calldata,\n        bytes calldata\n    ) external virtual override {}\n\n    ///@inheritdoc ITaskModule\n    function preCancelTask(bytes32, address _taskCreator)\n        external\n        virtual\n        override\n        returns (address)\n    {\n        return _taskCreator;\n    }\n\n    ///@inheritdoc ITaskModule\n    function preExecCall(\n        bytes32,\n        address,\n        address _execAddress,\n        bytes calldata _execData\n    ) external virtual override returns (address, bytes memory) {\n        return (_execAddress, _execData);\n    }\n\n    ///@inheritdoc ITaskModule\n    function postExecCall(\n        bytes32 taskId,\n        address taskCreator,\n        address execAddress,\n        bytes calldata execData\n    ) external virtual override {}\n}\n"
    },
    "contracts/libraries/LibDataTypes.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.12;\n\n// solhint-disable max-line-length\nlibrary LibDataTypes {\n    /**\n     * @notice Whitelisted modules that are available for users to customise conditions and specifications of their tasks.\n     *\n     * @param RESOLVER Use dynamic condition & input data for execution. {See ResolverModule.sol}\n     * @param TIME Repeated execution of task at a specified timing and interval. {See TimeModule.sol}\n     * @param PROXY Creates a dedicated caller (msg.sender) to be used when executing the task. {See ProxyModule.sol}\n     * @param SINGLE_EXEC Task is cancelled after one execution. {See SingleExecModule.sol}\n     * @param WEB3_FUNCTION Use off-chain condition & input data for execution. {See Web3FunctionModule.sol}\n     */\n    enum Module {\n        RESOLVER,\n        TIME,\n        PROXY,\n        SINGLE_EXEC,\n        WEB3_FUNCTION\n    }\n\n    /**\n     * @notice Struct to contain modules and their relative arguments that are used for task creation.\n     *\n     * @param modules List of selected modules.\n     * @param args Arguments of modules if any. Pass \"0x\" for modules which does not require args {See encodeModuleArg}\n     */\n    struct ModuleData {\n        Module[] modules;\n        bytes[] args;\n    }\n\n    /**\n     * @notice Struct for time module.\n     *\n     * @param nextExec Time when the next execution should occur.\n     * @param interval Time interval between each execution.\n     */\n    struct Time {\n        uint128 nextExec;\n        uint128 interval;\n    }\n}\n"
    },
    "contracts/OpsStorage.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {LibDataTypes} from \"./libraries/LibDataTypes.sol\";\n\n/**\n * @notice Storage layout of Ops smart contract.\n */\n// solhint-disable max-states-count\nabstract contract OpsStorage {\n    mapping(bytes32 => address) public taskCreator; ///@dev Deprecated\n    mapping(bytes32 => address) public execAddresses; ///@dev Deprecated\n    mapping(address => EnumerableSet.Bytes32Set) internal _createdTasks;\n\n    uint256 public fee;\n    address public feeToken;\n\n    ///@dev Appended State\n    mapping(bytes32 => LibDataTypes.Time) public timedTask;\n    mapping(LibDataTypes.Module => address) public taskModuleAddresses;\n    mapping(bytes32 => uint256) public nonce1Balance;\n}\n"
    },
    "contracts/interfaces/ITaskModule.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.12;\n\n// solhint-disable max-line-length\ninterface ITaskModule {\n    /**\n     * @notice Called before generating taskId.\n     * @dev Modules can override execAddress or taskCreator. {See ProxyModule-preCreateTask}\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called.\n     *\n     * @return address Overriden or original taskCreator.\n     * @return address Overriden or original execAddress.\n     */\n    function preCreateTask(address taskCreator, address execAddress)\n        external\n        returns (address, address);\n\n    /**\n     * @notice Initiates task module whenever `createTask` is being called.\n     *\n     * @param taskId Unique hash of the task created.\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     * @param initModuleArg Encoded arguments for module if any.\n     */\n    function onCreateTask(\n        bytes32 taskId,\n        address taskCreator,\n        address execAddress,\n        bytes calldata execData,\n        bytes calldata initModuleArg\n    ) external;\n\n    /**\n     * @notice Called before taskId is removed from _createdTasks[].\n     * @dev Modules can override taskCreator.\n     *\n     * @param taskId Unique hash of the task created.\n     * @param taskCreator The address which created the task.\n     *\n     * @return address Overriden or original taskCreator.\n     */\n    function preCancelTask(bytes32 taskId, address taskCreator)\n        external\n        returns (address);\n\n    /**\n     * @notice Called during `exec` and before execAddress is called.\n     *\n     * @param taskId Unique hash of the task created.\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     *\n     * @return address Overriden or original execution address.\n     * @return bytes Overriden or original execution data.\n     */\n    function preExecCall(\n        bytes32 taskId,\n        address taskCreator,\n        address execAddress,\n        bytes calldata execData\n    ) external returns (address, bytes memory);\n\n    /**\n     * @notice Called during `exec` and after execAddress is called.\n     *\n     * @param taskId Unique hash of the task created.\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     */\n    function postExecCall(\n        bytes32 taskId,\n        address taskCreator,\n        address execAddress,\n        bytes calldata execData\n    ) external;\n}\n"
    },
    "@openzeppelin/contracts/utils/structs/EnumerableSet.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/structs/EnumerableSet.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Library for managing\n * https://en.wikipedia.org/wiki/Set_(abstract_data_type)[sets] of primitive\n * types.\n *\n * Sets have the following properties:\n *\n * - Elements are added, removed, and checked for existence in constant time\n * (O(1)).\n * - Elements are enumerated in O(n). No guarantees are made on the ordering.\n *\n * ```\n * contract Example {\n *     // Add the library methods\n *     using EnumerableSet for EnumerableSet.AddressSet;\n *\n *     // Declare a set state variable\n *     EnumerableSet.AddressSet private mySet;\n * }\n * ```\n *\n * As of v3.3.0, sets of type `bytes32` (`Bytes32Set`), `address` (`AddressSet`)\n * and `uint256` (`UintSet`) are supported.\n */\nlibrary EnumerableSet {\n    // To implement this library for multiple types with as little code\n    // repetition as possible, we write it in terms of a generic Set type with\n    // bytes32 values.\n    // The Set implementation uses private functions, and user-facing\n    // implementations (such as AddressSet) are just wrappers around the\n    // underlying Set.\n    // This means that we can only create new EnumerableSets for types that fit\n    // in bytes32.\n\n    struct Set {\n        // Storage of set values\n        bytes32[] _values;\n        // Position of the value in the `values` array, plus 1 because index 0\n        // means a value is not in the set.\n        mapping(bytes32 => uint256) _indexes;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function _add(Set storage set, bytes32 value) private returns (bool) {\n        if (!_contains(set, value)) {\n            set._values.push(value);\n            // The value is stored at length-1, but we add 1 to all indexes\n            // and use 0 as a sentinel value\n            set._indexes[value] = set._values.length;\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function _remove(Set storage set, bytes32 value) private returns (bool) {\n        // We read and store the value's index to prevent multiple reads from the same storage slot\n        uint256 valueIndex = set._indexes[value];\n\n        if (valueIndex != 0) {\n            // Equivalent to contains(set, value)\n            // To delete an element from the _values array in O(1), we swap the element to delete with the last one in\n            // the array, and then remove the last element (sometimes called as 'swap and pop').\n            // This modifies the order of the array, as noted in {at}.\n\n            uint256 toDeleteIndex = valueIndex - 1;\n            uint256 lastIndex = set._values.length - 1;\n\n            if (lastIndex != toDeleteIndex) {\n                bytes32 lastvalue = set._values[lastIndex];\n\n                // Move the last value to the index where the value to delete is\n                set._values[toDeleteIndex] = lastvalue;\n                // Update the index for the moved value\n                set._indexes[lastvalue] = valueIndex; // Replace lastvalue's index to valueIndex\n            }\n\n            // Delete the slot where the moved value was stored\n            set._values.pop();\n\n            // Delete the index for the deleted slot\n            delete set._indexes[value];\n\n            return true;\n        } else {\n            return false;\n        }\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function _contains(Set storage set, bytes32 value) private view returns (bool) {\n        return set._indexes[value] != 0;\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function _length(Set storage set) private view returns (uint256) {\n        return set._values.length;\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function _at(Set storage set, uint256 index) private view returns (bytes32) {\n        return set._values[index];\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function _values(Set storage set) private view returns (bytes32[] memory) {\n        return set._values;\n    }\n\n    // Bytes32Set\n\n    struct Bytes32Set {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _add(set._inner, value);\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(Bytes32Set storage set, bytes32 value) internal returns (bool) {\n        return _remove(set._inner, value);\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(Bytes32Set storage set, bytes32 value) internal view returns (bool) {\n        return _contains(set._inner, value);\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(Bytes32Set storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(Bytes32Set storage set, uint256 index) internal view returns (bytes32) {\n        return _at(set._inner, index);\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(Bytes32Set storage set) internal view returns (bytes32[] memory) {\n        return _values(set._inner);\n    }\n\n    // AddressSet\n\n    struct AddressSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(AddressSet storage set, address value) internal returns (bool) {\n        return _add(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(AddressSet storage set, address value) internal returns (bool) {\n        return _remove(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(AddressSet storage set, address value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(uint256(uint160(value))));\n    }\n\n    /**\n     * @dev Returns the number of values in the set. O(1).\n     */\n    function length(AddressSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(AddressSet storage set, uint256 index) internal view returns (address) {\n        return address(uint160(uint256(_at(set._inner, index))));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(AddressSet storage set) internal view returns (address[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        address[] memory result;\n\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n\n    // UintSet\n\n    struct UintSet {\n        Set _inner;\n    }\n\n    /**\n     * @dev Add a value to a set. O(1).\n     *\n     * Returns true if the value was added to the set, that is if it was not\n     * already present.\n     */\n    function add(UintSet storage set, uint256 value) internal returns (bool) {\n        return _add(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Removes a value from a set. O(1).\n     *\n     * Returns true if the value was removed from the set, that is if it was\n     * present.\n     */\n    function remove(UintSet storage set, uint256 value) internal returns (bool) {\n        return _remove(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns true if the value is in the set. O(1).\n     */\n    function contains(UintSet storage set, uint256 value) internal view returns (bool) {\n        return _contains(set._inner, bytes32(value));\n    }\n\n    /**\n     * @dev Returns the number of values on the set. O(1).\n     */\n    function length(UintSet storage set) internal view returns (uint256) {\n        return _length(set._inner);\n    }\n\n    /**\n     * @dev Returns the value stored at position `index` in the set. O(1).\n     *\n     * Note that there are no guarantees on the ordering of values inside the\n     * array, and it may change when more values are added or removed.\n     *\n     * Requirements:\n     *\n     * - `index` must be strictly less than {length}.\n     */\n    function at(UintSet storage set, uint256 index) internal view returns (uint256) {\n        return uint256(_at(set._inner, index));\n    }\n\n    /**\n     * @dev Return the entire set in an array\n     *\n     * WARNING: This operation will copy the entire storage to memory, which can be quite expensive. This is designed\n     * to mostly be used by view accessors that are queried without any gas fees. Developers should keep in mind that\n     * this function has an unbounded cost, and using it as part of a state-changing function may render the function\n     * uncallable if the set grows to a point where copying to memory consumes too much gas to fit in a block.\n     */\n    function values(UintSet storage set) internal view returns (uint256[] memory) {\n        bytes32[] memory store = _values(set._inner);\n        uint256[] memory result;\n\n        assembly {\n            result := store\n        }\n\n        return result;\n    }\n}\n"
    },
    "contracts/taskModules/TimeModule.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {TaskModuleBase} from \"./TaskModuleBase.sol\";\nimport {LibDataTypes} from \"../libraries/LibDataTypes.sol\";\nimport {LibEvents} from \"../libraries/LibEvents.sol\";\n\n// solhint-disable not-rely-on-time\ncontract TimeModule is TaskModuleBase {\n    ///@inheritdoc TaskModuleBase\n    function onCreateTask(\n        bytes32 _taskId,\n        address,\n        address,\n        bytes calldata,\n        bytes calldata _arg\n    ) external override {\n        (uint128 startTime, uint128 interval) = _decodeModuleArg(_arg);\n\n        uint128 nextExec = uint256(startTime) > block.timestamp\n            ? startTime\n            : uint128(block.timestamp);\n\n        timedTask[_taskId] = LibDataTypes.Time(nextExec, interval);\n\n        emit LibEvents.TimerSet(_taskId, nextExec, interval);\n    }\n\n    function preCancelTask(bytes32 _taskId, address _taskCreator)\n        external\n        override\n        returns (address)\n    {\n        delete timedTask[_taskId];\n\n        return _taskCreator;\n    }\n\n    /**\n     * @inheritdoc TaskModuleBase\n     * @dev Time is updated at preExec because if\n     * SingleExec is used concurrently, it will delete timedTask.\n     */\n    function preExecCall(\n        bytes32 _taskId,\n        address,\n        address _execAddress,\n        bytes calldata _execData\n    ) external override returns (address, bytes memory) {\n        LibDataTypes.Time memory time = timedTask[_taskId];\n        bool isTimedTask = time.nextExec != 0;\n\n        if (isTimedTask) {\n            require(\n                time.nextExec <= uint128(block.timestamp),\n                \"TimeModule: Too early\"\n            );\n\n            uint128 timeDiff = uint128(block.timestamp) - time.nextExec;\n            uint128 intervals = (timeDiff / time.interval) + 1;\n\n            timedTask[_taskId].nextExec =\n                time.nextExec +\n                (intervals * time.interval);\n        }\n        return (_execAddress, _execData);\n    }\n\n    /**\n     * @notice Helper function to encode arguments for TimeModule.\n     *\n     * @param _startTime Time when the first execution should occur.\n     * @param _interval Time interval between each execution.\n     */\n    function encodeModuleArg(address _startTime, bytes calldata _interval)\n        external\n        pure\n        returns (bytes memory)\n    {\n        return abi.encode(_startTime, _interval);\n    }\n\n    function _decodeModuleArg(bytes calldata _arg)\n        private\n        pure\n        returns (uint128 startTime, uint128 interval)\n    {\n        (startTime, interval) = abi.decode(_arg, (uint128, uint128));\n    }\n}\n"
    },
    "contracts/libraries/LibEvents.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.12;\n\nimport {LibDataTypes} from \"./LibDataTypes.sol\";\n\nlibrary LibEvents {\n    /**\n     * @notice Emitted when `createTask` is called.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that is called by Gelato.\n     * @param execDataOrSelector Execution data / function selector.\n     * @param moduleData Conditional modules used. {See LibDataTypes-ModuleData}\n     * @param feeToken Token used to pay for the execution. ETH = 0xeeeeee...\n     * @param taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     */\n    event TaskCreated(\n        address indexed taskCreator,\n        address indexed execAddress,\n        bytes execDataOrSelector,\n        LibDataTypes.ModuleData moduleData,\n        address feeToken,\n        bytes32 indexed taskId\n    );\n\n    /**\n     * @notice Emitted when `cancelTask` is called.\n     *\n     * @param taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param taskCreator The address which owned the task.\n     */\n    event TaskCancelled(bytes32 taskId, address taskCreator);\n\n    /**\n     * @notice Emitted when `exec` is called.\n     *\n     * @param txFee Fee paid to Gelato for execution\n     * @param feeToken Token used to pay for the execution. ETH = 0xeeeeee...\n     * @param execAddress Address of contract that will be called by Gelato.\n     * @param execData Execution data / function selector.\n     * @param taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param callSuccess Status of the call to execAddress.\n     */\n    event ExecSuccess(\n        uint256 indexed txFee,\n        address indexed feeToken,\n        address indexed execAddress,\n        bytes execData,\n        bytes32 taskId,\n        bool callSuccess\n    );\n\n    /**\n     * @notice Emitted when TimeModule is initialised.\n     *\n     * @param taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param nextExec Time when the next execution will occur.\n     * @param interval Time interval between each execution.\n     */\n    event TimerSet(\n        bytes32 indexed taskId,\n        uint128 indexed nextExec,\n        uint128 indexed interval\n    );\n}\n"
    },
    "contracts/taskModules/SingleExecModule.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {TaskModuleBase} from \"./TaskModuleBase.sol\";\nimport {LibEvents} from \"../libraries/LibEvents.sol\";\n\ncontract SingleExecModule is TaskModuleBase {\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    /// @inheritdoc TaskModuleBase\n    function postExecCall(\n        bytes32 _taskId,\n        address _taskCreator,\n        address,\n        bytes calldata\n    ) external override {\n        _createdTasks[_taskCreator].remove(_taskId);\n        delete timedTask[_taskId];\n\n        emit LibEvents.TaskCancelled(_taskId, _taskCreator);\n    }\n}\n"
    },
    "contracts/taskModules/ResolverModule.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {TaskModuleBase} from \"./TaskModuleBase.sol\";\n\ncontract ResolverModule is TaskModuleBase {\n    /**\n     * @notice Helper function to encode arguments for ResolverModule.\n     *\n     * @param _resolverAddress Address of resolver.\n     * @param _resolverData Data passed to resolver.\n     */\n    function encodeModuleArg(\n        address _resolverAddress,\n        bytes calldata _resolverData\n    ) external pure returns (bytes memory) {\n        return abi.encode(_resolverAddress, _resolverData);\n    }\n}\n"
    },
    "contracts/libraries/LibTaskModule.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.12;\n\nimport {_call, _delegateCall} from \"../functions/FExec.sol\";\nimport {LibDataTypes} from \"./LibDataTypes.sol\";\nimport {LibTaskModuleConfig} from \"./LibTaskModuleConfig.sol\";\nimport {ITaskModule} from \"../interfaces/ITaskModule.sol\";\n\n/**\n * @notice Library to call task modules on task creation and execution.\n */\nlibrary LibTaskModule {\n    using LibTaskModuleConfig for LibDataTypes.Module;\n\n    /**\n     * @notice Delegate calls task modules before generating taskId.\n     *\n     * @param _execAddress Address of contract that will be called by Gelato.\n     * @param _taskCreator The address which created the task.\n     * @param taskModuleAddresses The storage reference to the mapping of modules to their address.\n     */\n    function preCreateTask(\n        address _taskCreator,\n        address _execAddress,\n        mapping(LibDataTypes.Module => address) storage taskModuleAddresses\n    ) internal returns (address, address) {\n        uint256 length = uint256(type(LibDataTypes.Module).max);\n\n        for (uint256 i; i <= length; i++) {\n            LibDataTypes.Module module = LibDataTypes.Module(i);\n            if (!module.requirePreCreate()) continue;\n\n            address moduleAddress = taskModuleAddresses[module];\n            _moduleInitialised(moduleAddress);\n\n            bytes memory delegatecallData = abi.encodeWithSelector(\n                ITaskModule.preCreateTask.selector,\n                _taskCreator,\n                _execAddress\n            );\n\n            (, bytes memory returnData) = _delegateCall(\n                moduleAddress,\n                delegatecallData,\n                \"Ops.preCreateTask: \"\n            );\n\n            (_taskCreator, _execAddress) = abi.decode(\n                returnData,\n                (address, address)\n            );\n        }\n\n        return (_taskCreator, _execAddress);\n    }\n\n    /**\n     * @notice Delegate calls task modules on create task to initialise them.\n     *\n     * @param _taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param _taskCreator The address which created the task.\n     * @param _execAddress Address of contract that will be called by Gelato.\n     * @param _execData Execution data to be called with / function selector.\n     * @param _moduleData Modules that will be used for the task. {See LibDataTypes-ModuleData}\n     * @param taskModuleAddresses The storage reference to the mapping of modules to their address.\n     */\n    function onCreateTask(\n        bytes32 _taskId,\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.ModuleData memory _moduleData,\n        mapping(LibDataTypes.Module => address) storage taskModuleAddresses\n    ) internal {\n        uint256 length = _moduleData.modules.length;\n\n        _validModules(length, _moduleData.modules);\n\n        for (uint256 i; i < length; i++) {\n            LibDataTypes.Module module = _moduleData.modules[i];\n            if (!module.requireOnCreate()) continue;\n\n            address moduleAddress = taskModuleAddresses[module];\n            _moduleInitialised(moduleAddress);\n\n            bytes memory delegatecallData = abi.encodeWithSelector(\n                ITaskModule.onCreateTask.selector,\n                _taskId,\n                _taskCreator,\n                _execAddress,\n                _execData,\n                _moduleData.args[i]\n            );\n\n            _delegateCall(\n                moduleAddress,\n                delegatecallData,\n                \"Ops.onCreateTask: \"\n            );\n        }\n    }\n\n    /**\n     * @notice Delegate calls task modules before removing task.\n     *\n     * @param _taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param _taskCreator The address which created the task.\n     * @param taskModuleAddresses The storage reference to the mapping of modules to their address.\n     */\n    function preCancelTask(\n        bytes32 _taskId,\n        address _taskCreator,\n        mapping(LibDataTypes.Module => address) storage taskModuleAddresses\n    ) internal returns (address) {\n        uint256 length = uint256(type(LibDataTypes.Module).max);\n\n        for (uint256 i; i <= length; i++) {\n            LibDataTypes.Module module = LibDataTypes.Module(i);\n\n            if (!module.requirePreCancel()) continue;\n\n            address moduleAddress = taskModuleAddresses[module];\n            _moduleInitialised(moduleAddress);\n\n            bytes memory delegatecallData = abi.encodeWithSelector(\n                ITaskModule.preCancelTask.selector,\n                _taskId,\n                _taskCreator\n            );\n\n            (, bytes memory returnData) = _delegateCall(\n                moduleAddress,\n                delegatecallData,\n                \"Ops.preCancelTask: \"\n            );\n\n            (_taskCreator) = abi.decode(returnData, (address));\n        }\n\n        return _taskCreator;\n    }\n\n    /**\n     * @notice Delegate calls task modules on exec.\n     *\n     * @param _taskId Unique hash of the task. {See LibTaskId-getTaskId}\n     * @param _taskCreator The address which created the task.\n     * @param _execAddress Address of contract that will be called by Gelato.\n     * @param _execData Execution data to be called with / function selector.\n     * @param _modules Modules that is used for the task. {See LibDataTypes-Module}\n     * @param _revertOnFailure To revert or not if call to execAddress fails.\n     * @param taskModuleAddresses The storage reference to the mapping of modules to their address.\n     */\n    function onExecTask(\n        bytes32 _taskId,\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.Module[] memory _modules,\n        bool _revertOnFailure,\n        mapping(LibDataTypes.Module => address) storage taskModuleAddresses\n    ) internal returns (bool callSuccess) {\n        address[] memory moduleAddresses = _getModuleAddresses(\n            _modules,\n            taskModuleAddresses\n        );\n\n        (_execAddress, _execData) = _preExecCall(\n            _taskId,\n            _taskCreator,\n            _execAddress,\n            _execData,\n            _modules,\n            moduleAddresses\n        );\n\n        (callSuccess, ) = _call(\n            _execAddress,\n            abi.encodePacked(_execData, _taskCreator),\n            0,\n            _revertOnFailure,\n            \"Ops.exec: \"\n        );\n\n        _postExecCall(\n            _taskId,\n            _taskCreator,\n            _execAddress,\n            _execData,\n            _modules,\n            moduleAddresses\n        );\n    }\n\n    function _preExecCall(\n        bytes32 _taskId,\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.Module[] memory _modules,\n        address[] memory _moduleAddresses\n    ) private returns (address, bytes memory) {\n        uint256 length = _modules.length;\n\n        for (uint256 i; i < length; i++) {\n            if (!_modules[i].requirePreExec()) continue;\n\n            bytes memory delegatecallData = abi.encodeWithSelector(\n                ITaskModule.preExecCall.selector,\n                _taskId,\n                _taskCreator,\n                _execAddress,\n                _execData\n            );\n\n            (, bytes memory returnData) = _delegateCall(\n                _moduleAddresses[i],\n                delegatecallData,\n                \"Ops.preExecCall: \"\n            );\n\n            (_execAddress, _execData) = abi.decode(\n                returnData,\n                (address, bytes)\n            );\n        }\n        return (_execAddress, _execData);\n    }\n\n    function _postExecCall(\n        bytes32 _taskId,\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.Module[] memory _modules,\n        address[] memory _moduleAddresses\n    ) private {\n        uint256 length = _moduleAddresses.length;\n\n        for (uint256 i; i < length; i++) {\n            if (!_modules[i].requirePostExec()) continue;\n\n            bytes memory delegatecallData = abi.encodeWithSelector(\n                ITaskModule.postExecCall.selector,\n                _taskId,\n                _taskCreator,\n                _execAddress,\n                _execData\n            );\n\n            _delegateCall(\n                _moduleAddresses[i],\n                delegatecallData,\n                \"Ops.postExecCall: \"\n            );\n        }\n    }\n\n    function _getModuleAddresses(\n        LibDataTypes.Module[] memory _modules,\n        mapping(LibDataTypes.Module => address) storage taskModuleAddresses\n    ) private view returns (address[] memory) {\n        uint256 length = _modules.length;\n        address[] memory moduleAddresses = new address[](length);\n\n        for (uint256 i; i < length; i++) {\n            moduleAddresses[i] = taskModuleAddresses[_modules[i]];\n        }\n\n        return moduleAddresses;\n    }\n\n    function _moduleInitialised(address _moduleAddress) private pure {\n        require(\n            _moduleAddress != address(0),\n            \"Ops._moduleInitialised: Not init\"\n        );\n    }\n\n    /**\n     * @dev\n     * - No duplicate modules.\n     * - No RESOLVER && WEB3_FUNCTION\n     */\n    function _validModules(\n        uint256 _length,\n        LibDataTypes.Module[] memory _modules\n    ) private pure {\n        if (_length > 1) {\n            bool hasResolver = _modules[0] == LibDataTypes.Module.RESOLVER;\n            for (uint256 i; i < _length - 1; i++) {\n                require(\n                    _modules[i + 1] > _modules[i],\n                    \"Ops._validModules: Asc only\"\n                );\n                if (hasResolver)\n                    require(\n                        _modules[i + 1] != LibDataTypes.Module.WEB3_FUNCTION,\n                        \"Ops._validModules: Only one resolver\"\n                    );\n            }\n        }\n    }\n}\n"
    },
    "contracts/libraries/LibTaskModuleConfig.sol": {
      "content": "// SPDX-License-Identifier: MIT\n\npragma solidity ^0.8.12;\n\nimport {LibDataTypes} from \"./LibDataTypes.sol\";\n\n/**\n * @notice Library to determine wether to call task modules to reduce unnecessary calls.\n */\nlibrary LibTaskModuleConfig {\n    function requirePreCreate(LibDataTypes.Module _module)\n        internal\n        pure\n        returns (bool)\n    {\n        if (_module == LibDataTypes.Module.PROXY) return true;\n\n        return false;\n    }\n\n    function requirePreCancel(LibDataTypes.Module _module)\n        internal\n        pure\n        returns (bool)\n    {\n        if (\n            _module == LibDataTypes.Module.TIME ||\n            _module == LibDataTypes.Module.PROXY\n        ) return true;\n\n        return false;\n    }\n\n    function requireOnCreate(LibDataTypes.Module _module)\n        internal\n        pure\n        returns (bool)\n    {\n        if (\n            _module == LibDataTypes.Module.TIME ||\n            _module == LibDataTypes.Module.PROXY\n        ) return true;\n\n        return false;\n    }\n\n    function requirePreExec(LibDataTypes.Module _module)\n        internal\n        pure\n        returns (bool)\n    {\n        if (\n            _module == LibDataTypes.Module.TIME ||\n            _module == LibDataTypes.Module.PROXY\n        ) return true;\n\n        return false;\n    }\n\n    function requirePostExec(LibDataTypes.Module _module)\n        internal\n        pure\n        returns (bool)\n    {\n        if (_module == LibDataTypes.Module.SINGLE_EXEC) return true;\n\n        return false;\n    }\n}\n"
    },
    "contracts/Ops.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {Gelatofied} from \"./vendor/gelato/Gelatofied.sol\";\nimport {GelatoBytes} from \"./vendor/gelato/GelatoBytes.sol\";\nimport {Proxied} from \"./vendor/proxy/EIP173/Proxied.sol\";\nimport {OpsStorage} from \"./OpsStorage.sol\";\nimport {LibDataTypes} from \"./libraries/LibDataTypes.sol\";\nimport {LibEvents} from \"./libraries/LibEvents.sol\";\nimport {LibLegacyTask} from \"./libraries/LibLegacyTask.sol\";\nimport {LibTaskId} from \"./libraries/LibTaskId.sol\";\nimport {LibTaskModule} from \"./libraries/LibTaskModule.sol\";\nimport {\n    ITaskTreasuryUpgradable\n} from \"./interfaces/ITaskTreasuryUpgradable.sol\";\nimport {IOps} from \"./interfaces/IOps.sol\";\n\n/**\n * @notice Ops enables everyone to have Gelato monitor and execute transactions.\n * @notice ExecAddress refers to the contract that has the function which Gelato will call.\n * @notice Modules allow users to customise conditions and specifications when creating a task.\n */\n//solhint-disable function-max-lines\ncontract Ops is Gelatofied, Proxied, OpsStorage, IOps {\n    using GelatoBytes for bytes;\n    using EnumerableSet for EnumerableSet.Bytes32Set;\n\n    // solhint-disable const-name-snakecase\n    string public constant version = \"5\";\n    ITaskTreasuryUpgradable public immutable override taskTreasury;\n\n    constructor(address payable _gelato, ITaskTreasuryUpgradable _taskTreasury)\n        Gelatofied(_gelato)\n    {\n        taskTreasury = _taskTreasury;\n    }\n\n    // prettier-ignore\n    fallback(bytes calldata _callData) external returns(bytes memory returnData){\n        returnData = _handleLegacyTaskCreation(_callData);\n    }\n\n    ///@inheritdoc IOps\n    function createTask(\n        address _execAddress,\n        bytes calldata _execDataOrSelector,\n        LibDataTypes.ModuleData calldata _moduleData,\n        address _feeToken\n    ) external override returns (bytes32 taskId) {\n        address taskCreator;\n\n        (taskCreator, _execAddress) = LibTaskModule.preCreateTask(\n            msg.sender,\n            _execAddress,\n            taskModuleAddresses\n        );\n\n        taskId = _createTask(\n            taskCreator,\n            _execAddress,\n            _execDataOrSelector,\n            _moduleData,\n            _feeToken\n        );\n    }\n\n    ///@inheritdoc IOps\n    function cancelTask(bytes32 _taskId) external {\n        address _taskCreator = LibTaskModule.preCancelTask(\n            _taskId,\n            msg.sender,\n            taskModuleAddresses\n        );\n\n        _cancelTask(_taskCreator, _taskId);\n    }\n\n    ///@inheritdoc IOps\n    function exec(\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.ModuleData calldata _moduleData,\n        uint256 _txFee,\n        address _feeToken,\n        bool _useTaskTreasuryFunds,\n        bool _revertOnFailure\n    ) external onlyGelato {\n        bytes32 taskId = LibTaskId.getTaskId(\n            _taskCreator,\n            _execAddress,\n            _execData.memorySliceSelector(),\n            _moduleData,\n            _useTaskTreasuryFunds ? address(0) : _feeToken\n        );\n\n        require(\n            _createdTasks[_taskCreator].contains(taskId),\n            \"Ops.exec: Task not found\"\n        );\n\n        if (!_useTaskTreasuryFunds) {\n            fee = _txFee;\n            feeToken = _feeToken;\n        }\n\n        bool success = LibTaskModule.onExecTask(\n            taskId,\n            _taskCreator,\n            _execAddress,\n            _execData,\n            _moduleData.modules,\n            _revertOnFailure,\n            taskModuleAddresses\n        );\n\n        if (_useTaskTreasuryFunds) {\n            taskTreasury.useFunds(_taskCreator, _feeToken, _txFee);\n        } else {\n            delete fee;\n            delete feeToken;\n        }\n\n        emit LibEvents.ExecSuccess(\n            _txFee,\n            _feeToken,\n            _execAddress,\n            _execData,\n            taskId,\n            success\n        );\n    }\n\n    ///@inheritdoc IOps\n    function exec1Balance(\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execData,\n        LibDataTypes.ModuleData calldata _moduleData,\n        Gelato1BalanceParam calldata _oneBalanceParam,\n        bool _revertOnFailure\n    ) external onlyGelato {\n        bytes32 taskId = LibTaskId.getTaskId(\n            _taskCreator,\n            _execAddress,\n            _execData.memorySliceSelector(),\n            _moduleData,\n            address(0) ///@dev a task with useTreasury=true can be charged with 1Balance / Treasury\n        );\n\n        require(\n            _createdTasks[_taskCreator].contains(taskId),\n            \"Ops.exec: Task not found\"\n        );\n\n        bool success = LibTaskModule.onExecTask(\n            taskId,\n            _taskCreator,\n            _execAddress,\n            _execData,\n            _moduleData.modules,\n            _revertOnFailure,\n            taskModuleAddresses\n        );\n\n        nonce1Balance[taskId] += 1;\n\n        emit LibEvents.ExecSuccess(\n            0,\n            address(0),\n            _execAddress,\n            _execData,\n            taskId,\n            success\n        );\n\n        emit LogUseGelato1Balance(\n            _oneBalanceParam.sponsor,\n            _execAddress,\n            _oneBalanceParam.feeToken,\n            _oneBalanceParam.oneBalanceChainId,\n            _oneBalanceParam.nativeToFeeTokenXRateNumerator,\n            _oneBalanceParam.nativeToFeeTokenXRateDenominator,\n            _oneBalanceParam.correlationId\n        );\n    }\n\n    ///@inheritdoc IOps\n    function setModule(\n        LibDataTypes.Module[] calldata _modules,\n        address[] calldata _moduleAddresses\n    ) external onlyProxyAdmin {\n        uint256 length = _modules.length;\n        for (uint256 i; i < length; i++) {\n            taskModuleAddresses[_modules[i]] = _moduleAddresses[i];\n        }\n    }\n\n    ///@inheritdoc IOps\n    function getFeeDetails() external view returns (uint256, address) {\n        return (fee, feeToken);\n    }\n\n    ///@inheritdoc IOps\n    function getTaskIdsByUser(address _taskCreator)\n        external\n        view\n        returns (bytes32[] memory)\n    {\n        bytes32[] memory taskIds = _createdTasks[_taskCreator].values();\n\n        return taskIds;\n    }\n\n    ///@inheritdoc IOps\n    function getTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        LibDataTypes.ModuleData memory moduleData,\n        address feeToken\n    ) external pure returns (bytes32 taskId) {\n        taskId = LibTaskId.getTaskId(\n            taskCreator,\n            execAddress,\n            execSelector,\n            moduleData,\n            feeToken\n        );\n    }\n\n    ///@inheritdoc IOps\n    function getTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        bool useTaskTreasuryFunds,\n        address feeToken,\n        bytes32 resolverHash\n    ) external pure returns (bytes32 taskId) {\n        taskId = LibTaskId.getLegacyTaskId(\n            taskCreator,\n            execAddress,\n            execSelector,\n            useTaskTreasuryFunds,\n            feeToken,\n            resolverHash\n        );\n    }\n\n    function _createTask(\n        address _taskCreator,\n        address _execAddress,\n        bytes memory _execDataOrSelector,\n        LibDataTypes.ModuleData memory _moduleData,\n        address _feeToken\n    ) private returns (bytes32 taskId) {\n        taskId = LibTaskId.getTaskId(\n            _taskCreator,\n            _execAddress,\n            _execDataOrSelector.memorySliceSelector(),\n            _moduleData,\n            _feeToken\n        );\n\n        require(\n            !_createdTasks[_taskCreator].contains(taskId),\n            \"Ops.createTask: Duplicate task\"\n        );\n\n        LibTaskModule.onCreateTask(\n            taskId,\n            _taskCreator,\n            _execAddress,\n            _execDataOrSelector,\n            _moduleData,\n            taskModuleAddresses\n        );\n\n        _createdTasks[_taskCreator].add(taskId);\n\n        emit LibEvents.TaskCreated(\n            _taskCreator,\n            _execAddress,\n            _execDataOrSelector,\n            _moduleData,\n            _feeToken,\n            taskId\n        );\n    }\n\n    function _cancelTask(address _taskCreator, bytes32 _taskId) private {\n        require(\n            _createdTasks[_taskCreator].contains(_taskId),\n            \"Ops.cancelTask: Task not found\"\n        );\n\n        _createdTasks[_taskCreator].remove(_taskId);\n\n        emit LibEvents.TaskCancelled(_taskId, _taskCreator);\n    }\n\n    function _handleLegacyTaskCreation(bytes calldata _callData)\n        private\n        returns (bytes memory returnData)\n    {\n        bytes4 funcSig = _callData.calldataSliceSelector();\n\n        (\n            address execAddress,\n            bytes memory execData,\n            LibDataTypes.ModuleData memory moduleData,\n            address feeToken_\n        ) = LibLegacyTask.getCreateTaskArg(funcSig, _callData);\n\n        bytes32 taskId = _createTask(\n            msg.sender,\n            execAddress,\n            execData,\n            moduleData,\n            feeToken_\n        );\n\n        returnData = abi.encodePacked(taskId);\n    }\n}\n"
    },
    "contracts/vendor/gelato/Gelatofied.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    SafeERC20,\n    IERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {_transfer, ETH} from \"../../functions/FUtils.sol\";\n\nabstract contract Gelatofied {\n    address payable public immutable gelato;\n\n    modifier gelatofy(uint256 _amount, address _paymentToken) {\n        require(msg.sender == gelato, \"Gelatofied: Only gelato\");\n        _;\n        _transfer(gelato, _paymentToken, _amount);\n    }\n\n    modifier onlyGelato() {\n        require(msg.sender == gelato, \"Gelatofied: Only gelato\");\n        _;\n    }\n\n    constructor(address payable _gelato) {\n        gelato = _gelato;\n    }\n}\n"
    },
    "contracts/vendor/proxy/EIP173/Proxied.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nabstract contract Proxied {\n    /// @notice to be used by initialisation / postUpgrade function so that only the proxy's admin can execute them\n    /// It also allows these functions to be called inside a contructor\n    /// even if the contract is meant to be used without proxy\n    modifier proxied() {\n        address proxyAdminAddress = _proxyAdmin();\n        // With hardhat-deploy proxies\n        // the proxyAdminAddress is zero only for the implementation contract\n        // if the implementation contract want to be used as a standalone/immutable contract\n        // it simply has to execute the `proxied` function\n        // This ensure the proxyAdminAddress is never zero post deployment\n        // And allow you to keep the same code for both proxied contract and immutable contract\n        if (proxyAdminAddress == address(0)) {\n            // ensure can not be called twice when used outside of proxy : no admin\n            // solhint-disable-next-line security/no-inline-assembly\n            assembly {\n                sstore(\n                    0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103,\n                    0xFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF\n                )\n            }\n        } else {\n            require(msg.sender == proxyAdminAddress);\n        }\n        _;\n    }\n\n    modifier onlyProxyAdmin() {\n        require(msg.sender == _proxyAdmin(), \"NOT_AUTHORIZED\");\n        _;\n    }\n\n    function _proxyAdmin() internal view returns (address adminAddress) {\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            adminAddress := sload(\n                0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n            )\n        }\n    }\n}\n"
    },
    "contracts/libraries/LibLegacyTask.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\nimport {LibDataTypes} from \"./LibDataTypes.sol\";\nimport {ILegacyOps} from \"../interfaces/ILegacyOps.sol\";\n\n/**\n * @notice Library to keep task creation methods backwards compatible.\n * @notice Legacy create task methods can be found in ILegacyOps.sol\n */\nlibrary LibLegacyTask {\n    /**\n     * @notice Use legacy ops create task calldata to construct\n     * arguments that conforms to current create task format.\n     *\n     * @param _funcSig Function signature of calldata.\n     * @param _callData Calldata that was passed from fallback function.\n     */\n    function getCreateTaskArg(bytes4 _funcSig, bytes calldata _callData)\n        internal\n        pure\n        returns (\n            address execAddress,\n            bytes memory execData,\n            LibDataTypes.ModuleData memory moduleData,\n            address feeToken\n        )\n    {\n        if (_funcSig == ILegacyOps.createTask.selector) {\n            (execAddress, execData, moduleData, feeToken) = _resolveCreateTask(\n                _callData[4:]\n            );\n        } else if (_funcSig == ILegacyOps.createTaskNoPrepayment.selector) {\n            (\n                execAddress,\n                execData,\n                moduleData,\n                feeToken\n            ) = _resolveCreateTaskNoPrepayment(_callData[4:]);\n        } else if (_funcSig == ILegacyOps.createTimedTask.selector) {\n            (\n                execAddress,\n                execData,\n                moduleData,\n                feeToken\n            ) = _resolveCreateTimedTask(_callData[4:]);\n        } else revert(\"Ops.createTask: Function not found\");\n    }\n\n    function _resolveCreateTask(bytes calldata _callDataSliced)\n        private\n        pure\n        returns (\n            address execAddress,\n            bytes memory execData,\n            LibDataTypes.ModuleData memory moduleData,\n            address feeToken\n        )\n    {\n        bytes4 execSelector;\n        address resolverAddress;\n        bytes memory resolverData;\n\n        (execAddress, execSelector, resolverAddress, resolverData) = abi.decode(\n            _callDataSliced,\n            (address, bytes4, address, bytes)\n        );\n\n        LibDataTypes.Module[] memory modules = new LibDataTypes.Module[](1);\n        modules[0] = LibDataTypes.Module.RESOLVER;\n\n        bytes[] memory args = new bytes[](1);\n        args[0] = abi.encode(resolverAddress, resolverData);\n\n        moduleData = LibDataTypes.ModuleData(modules, args);\n\n        execData = abi.encodePacked(execSelector);\n        feeToken = address(0);\n    }\n\n    function _resolveCreateTaskNoPrepayment(bytes calldata _callDataSliced)\n        private\n        pure\n        returns (\n            address execAddress,\n            bytes memory execData,\n            LibDataTypes.ModuleData memory moduleData,\n            address feeToken\n        )\n    {\n        bytes4 execSelector;\n        address resolverAddress;\n        bytes memory resolverData;\n\n        (\n            execAddress,\n            execSelector,\n            resolverAddress,\n            resolverData,\n            feeToken\n        ) = abi.decode(\n            _callDataSliced,\n            (address, bytes4, address, bytes, address)\n        );\n\n        LibDataTypes.Module[] memory modules = new LibDataTypes.Module[](1);\n        modules[0] = LibDataTypes.Module.RESOLVER;\n\n        bytes[] memory args = new bytes[](1);\n        args[0] = abi.encode(resolverAddress, resolverData);\n\n        moduleData = LibDataTypes.ModuleData(modules, args);\n\n        execData = abi.encodePacked(execSelector);\n    }\n\n    function _resolveCreateTimedTask(bytes calldata _callDataSliced)\n        private\n        pure\n        returns (\n            address execAddress,\n            bytes memory execData,\n            LibDataTypes.ModuleData memory moduleData,\n            address feeToken\n        )\n    {\n        bytes memory resolverModuleArgs;\n        bytes memory timeModuleArgs;\n        (\n            execAddress,\n            execData,\n            feeToken,\n            resolverModuleArgs,\n            timeModuleArgs\n        ) = _decodeTimedTaskCallData(_callDataSliced);\n        LibDataTypes.Module[] memory modules = new LibDataTypes.Module[](2);\n        modules[0] = LibDataTypes.Module.RESOLVER;\n        modules[1] = LibDataTypes.Module.TIME;\n\n        bytes[] memory args = new bytes[](2);\n        args[0] = resolverModuleArgs;\n        args[1] = timeModuleArgs;\n\n        moduleData = LibDataTypes.ModuleData(modules, args);\n    }\n\n    function _decodeTimedTaskCallData(bytes calldata _callDataSliced)\n        private\n        pure\n        returns (\n            address,\n            bytes memory,\n            address,\n            bytes memory,\n            bytes memory\n        )\n    {\n        (\n            uint128 startTime,\n            uint128 interval,\n            address execAddress,\n            bytes4 execSelector,\n            address resolverAddress,\n            bytes memory resolverData,\n            address feeToken,\n            bool useTreasury\n        ) = abi.decode(\n                _callDataSliced,\n                (\n                    uint128,\n                    uint128,\n                    address,\n                    bytes4,\n                    address,\n                    bytes,\n                    address,\n                    bool\n                )\n            );\n\n        return (\n            execAddress,\n            abi.encodePacked(execSelector),\n            feeToken = useTreasury ? address(0) : feeToken,\n            abi.encode(resolverAddress, resolverData),\n            abi.encode(startTime, interval)\n        );\n    }\n}\n"
    },
    "contracts/libraries/LibTaskId.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {LibDataTypes} from \"./LibDataTypes.sol\";\n\n/**\n * @notice Library to compute taskId of legacy and current tasks.\n */\n// solhint-disable max-line-length\nlibrary LibTaskId {\n    /**\n     * @notice Returns taskId of taskCreator.\n     * @notice To maintain the taskId of legacy tasks, if\n     * resolver module or resolver and time module is used,\n     * we will compute task id the legacy way.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that will be called by Gelato.\n     * @param execSelector Signature of the function which will be called by Gelato.\n     * @param moduleData  Conditional modules that will be used. {See LibDataTypes-ModuleData}\n     * @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens.\n     */\n    function getTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        LibDataTypes.ModuleData memory moduleData,\n        address feeToken\n    ) internal pure returns (bytes32 taskId) {\n        if (_shouldGetLegacyTaskId(moduleData.modules)) {\n            bytes32 resolverHash = _getResolverHash(moduleData.args[0]);\n\n            taskId = getLegacyTaskId(\n                taskCreator,\n                execAddress,\n                execSelector,\n                feeToken == address(0),\n                feeToken,\n                resolverHash\n            );\n        } else {\n            taskId = keccak256(\n                abi.encode(\n                    taskCreator,\n                    execAddress,\n                    execSelector,\n                    moduleData,\n                    feeToken\n                )\n            );\n        }\n    }\n\n    /**\n     * @notice Returns taskId of taskCreator.\n     * @notice Legacy way of computing taskId.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that will be called by Gelato.\n     * @param execSelector Signature of the function which will be called by Gelato.\n     * @param useTaskTreasuryFunds Wether fee should be deducted from TaskTreasury.\n     * @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens.\n     * @param resolverHash Hash of resolverAddress and resolverData {See getResolverHash}\n     */\n    function getLegacyTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        bool useTaskTreasuryFunds,\n        address feeToken,\n        bytes32 resolverHash\n    ) internal pure returns (bytes32) {\n        return\n            keccak256(\n                abi.encode(\n                    taskCreator,\n                    execAddress,\n                    execSelector,\n                    useTaskTreasuryFunds,\n                    feeToken,\n                    resolverHash\n                )\n            );\n    }\n\n    /**\n     * @dev For legacy tasks, resolvers are compulsory. Time tasks were also introduced.\n     * The sequence of Module is enforced in {LibTaskModule-_validModules}\n     */\n    function _shouldGetLegacyTaskId(LibDataTypes.Module[] memory _modules)\n        private\n        pure\n        returns (bool)\n    {\n        uint256 length = _modules.length;\n\n        if (\n            (length == 1 && _modules[0] == LibDataTypes.Module.RESOLVER) ||\n            (length == 2 &&\n                _modules[0] == LibDataTypes.Module.RESOLVER &&\n                _modules[1] == LibDataTypes.Module.TIME)\n        ) return true;\n\n        return false;\n    }\n\n    /**\n     * @dev Acquire resolverHash which is required to compute legacyTaskId.\n     *\n     * @param _resolverModuleArg Encoded value of resolverAddress and resolverData\n     */\n    function _getResolverHash(bytes memory _resolverModuleArg)\n        private\n        pure\n        returns (bytes32)\n    {\n        return keccak256(_resolverModuleArg);\n    }\n}\n"
    },
    "contracts/interfaces/ITaskTreasuryUpgradable.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITaskTreasuryUpgradable {\n    /// @notice Events ///\n\n    event FundsDeposited(\n        address indexed sender,\n        address indexed token,\n        uint256 indexed amount\n    );\n\n    event FundsWithdrawn(\n        address indexed receiver,\n        address indexed initiator,\n        address indexed token,\n        uint256 amount\n    );\n\n    event LogDeductFees(\n        address indexed user,\n        address indexed executor,\n        address indexed token,\n        uint256 fees,\n        address service\n    );\n\n    event UpdatedService(address indexed service, bool add);\n\n    event UpdatedMaxFee(uint256 indexed maxFee);\n\n    /// @notice External functions ///\n\n    function depositFunds(\n        address receiver,\n        address token,\n        uint256 amount\n    ) external payable;\n\n    function withdrawFunds(\n        address payable receiver,\n        address token,\n        uint256 amount\n    ) external;\n\n    function useFunds(\n        address user,\n        address token,\n        uint256 amount\n    ) external;\n\n    function updateMaxFee(uint256 _newMaxFee) external;\n\n    function updateWhitelistedService(address service, bool isWhitelist)\n        external;\n\n    /// @notice External view functions ///\n\n    function getCreditTokensByUser(address user)\n        external\n        view\n        returns (address[] memory);\n\n    function getTotalCreditTokensByUser(address user)\n        external\n        view\n        returns (address[] memory);\n\n    function getWhitelistedServices() external view returns (address[] memory);\n\n    function totalUserTokenBalance(address user, address token)\n        external\n        view\n        returns (uint256);\n\n    function userTokenBalance(address user, address token)\n        external\n        view\n        returns (uint256);\n}\n"
    },
    "contracts/interfaces/IOps.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\nimport {LibDataTypes} from \"../libraries/LibDataTypes.sol\";\nimport {ITaskTreasuryUpgradable} from \"./ITaskTreasuryUpgradable.sol\";\nimport {IGelato1Balance} from \"./IGelato1Balance.sol\";\n\n// solhint-disable max-line-length\ninterface IOps is IGelato1Balance {\n    /**\n     * @notice Initiates a task with conditions which Gelato will monitor and execute when conditions are met.\n     *\n     * @param execAddress Address of contract that should be called by Gelato.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     * @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData}\n     * @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens.\n     *\n     * @return taskId Unique hash of the task created.\n     */\n    function createTask(\n        address execAddress,\n        bytes calldata execData,\n        LibDataTypes.ModuleData calldata moduleData,\n        address feeToken\n    ) external returns (bytes32 taskId);\n\n    /**\n     * @notice Terminates a task that was created and Gelato can no longer execute it.\n     *\n     * @param taskId Unique hash of the task that is being cancelled. {See LibTaskId-getTaskId}\n     */\n    function cancelTask(bytes32 taskId) external;\n\n    /**\n     * @notice Execution API called by Gelato.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called by Gelato.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     * @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData}\n     * @param txFee Fee paid to Gelato for execution, deducted on the TaskTreasury or transfered to Gelato.\n     * @param feeToken Token used to pay for the execution. ETH = 0xeeeeee...\n     * @param useTaskTreasuryFunds If taskCreator's balance on TaskTreasury should pay for the tx.\n     * @param revertOnFailure To revert or not if call to execAddress fails. (Used for off-chain simulations)\n     */\n    function exec(\n        address taskCreator,\n        address execAddress,\n        bytes memory execData,\n        LibDataTypes.ModuleData calldata moduleData,\n        uint256 txFee,\n        address feeToken,\n        bool useTaskTreasuryFunds,\n        bool revertOnFailure\n    ) external;\n\n    /**\n     * @notice Execution API called by Gelato, using Gelato 1Balance as fee payment method.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that should be called by Gelato.\n     * @param execData Execution data to be called with / function selector if execution data is yet to be determined.\n     * @param moduleData Conditional modules that will be used. {See LibDataTypes-ModuleData}\n     * @param oneBalanceParam Parameters required for fee payment with Gelato 1Balance.\n     * @param revertOnFailure To revert or not if call to execAddress fails. (Used for off-chain simulations)\n     */\n    function exec1Balance(\n        address taskCreator,\n        address execAddress,\n        bytes memory execData,\n        LibDataTypes.ModuleData calldata moduleData,\n        Gelato1BalanceParam calldata oneBalanceParam,\n        bool revertOnFailure\n    ) external;\n\n    /**\n     * @notice Sets the address of task modules. Only callable by proxy admin.\n     *\n     * @param modules List of modules to be set\n     * @param moduleAddresses List of addresses for respective modules.\n     */\n    function setModule(\n        LibDataTypes.Module[] calldata modules,\n        address[] calldata moduleAddresses\n    ) external;\n\n    /**\n     * @notice Helper function to query fee and feeToken to be used for payment. (For executions which pays itself)\n     *\n     * @return uint256 Fee amount to be paid.\n     * @return address Token to be paid. (Determined and passed by taskCreator during createTask)\n     */\n    function getFeeDetails() external view returns (uint256, address);\n\n    /**\n     * @notice Helper func to query all open tasks by a task creator.\n     *\n     * @param taskCreator Address of task creator to query.\n     *\n     * @return bytes32[] List of taskIds created.\n     */\n    function getTaskIdsByUser(address taskCreator)\n        external\n        view\n        returns (bytes32[] memory);\n\n    /**\n     * @notice Helper function to compute task id with module arguments\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that will be called by Gelato.\n     * @param execSelector Signature of the function which will be called by Gelato.\n     * @param moduleData  Conditional modules that will be used. {See LibDataTypes-ModuleData}\n     * @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens.\n     */\n    function getTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        LibDataTypes.ModuleData memory moduleData,\n        address feeToken\n    ) external pure returns (bytes32 taskId);\n\n    /**\n     * @notice (Legacy) Helper function to compute task id.\n     *\n     * @param taskCreator The address which created the task.\n     * @param execAddress Address of contract that will be called by Gelato.\n     * @param execSelector Signature of the function which will be called by Gelato.\n     * @param useTaskTreasuryFunds Wether fee should be deducted from TaskTreasury.\n     * @param feeToken Address of token to be used as payment. Use address(0) if TaskTreasury is being used, 0xeeeeee... for ETH or native tokens.\n     * @param resolverHash Hash of resolverAddress and resolverData {See getResolverHash}\n     */\n    function getTaskId(\n        address taskCreator,\n        address execAddress,\n        bytes4 execSelector,\n        bool useTaskTreasuryFunds,\n        address feeToken,\n        bytes32 resolverHash\n    ) external pure returns (bytes32);\n\n    /**\n     * @notice TaskTreasury contract where user deposit funds to be used for fee payments.\n     *\n     * @return ITaskTreasuryUpgradable TaskTreasury contract interface\n     */\n    function taskTreasury() external view returns (ITaskTreasuryUpgradable);\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../../../utils/Address.sol\";\n\n/**\n * @title SafeERC20\n * @dev Wrappers around ERC20 operations that throw on failure (when the token\n * contract returns false). Tokens that return no value (and instead revert or\n * throw on failure) are also supported, non-reverting calls are assumed to be\n * successful.\n * To use this library you can add a `using SafeERC20 for IERC20;` statement to your contract,\n * which allows you to call the safe operations as `token.safeTransfer(...)`, etc.\n */\nlibrary SafeERC20 {\n    using Address for address;\n\n    function safeTransfer(\n        IERC20 token,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    function safeTransferFrom(\n        IERC20 token,\n        address from,\n        address to,\n        uint256 value\n    ) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transferFrom.selector, from, to, value));\n    }\n\n    /**\n     * @dev Deprecated. This function has issues similar to the ones found in\n     * {IERC20-approve}, and its usage is discouraged.\n     *\n     * Whenever possible, use {safeIncreaseAllowance} and\n     * {safeDecreaseAllowance} instead.\n     */\n    function safeApprove(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        // safeApprove should only be called when setting an initial allowance,\n        // or when resetting it to zero. To increase and decrease it, use\n        // 'safeIncreaseAllowance' and 'safeDecreaseAllowance'\n        require(\n            (value == 0) || (token.allowance(address(this), spender) == 0),\n            \"SafeERC20: approve from non-zero to non-zero allowance\"\n        );\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, value));\n    }\n\n    function safeIncreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        uint256 newAllowance = token.allowance(address(this), spender) + value;\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n    }\n\n    function safeDecreaseAllowance(\n        IERC20 token,\n        address spender,\n        uint256 value\n    ) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            uint256 newAllowance = oldAllowance - value;\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, newAllowance));\n        }\n    }\n\n    /**\n     * @dev Imitates a Solidity high-level call (i.e. a regular function call to a contract), relaxing the requirement\n     * on the return value: the return value is optional (but if data is returned, it must not be false).\n     * @param token The token targeted by the call.\n     * @param data The call data (encoded using abi.encode or one of its variants).\n     */\n    function _callOptionalReturn(IERC20 token, bytes memory data) private {\n        // We need to perform a low level call here, to bypass Solidity's return data size checking mechanism, since\n        // we're implementing it ourselves. We use {Address.functionCall} to perform this call, which verifies that\n        // the target address contains contract code and also asserts for success in the low-level call.\n\n        bytes memory returndata = address(token).functionCall(data, \"SafeERC20: low-level call failed\");\n        if (returndata.length > 0) {\n            // Return data is optional\n            require(abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\n        }\n    }\n}\n"
    },
    "contracts/functions/FUtils.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    SafeERC20,\n    IERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\naddress constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n// solhint-disable private-vars-leading-underscore\n// solhint-disable func-visibility\nfunction _transfer(\n    address payable _to,\n    address _paymentToken,\n    uint256 _amount\n) {\n    if (_paymentToken == ETH) {\n        (bool success, ) = _to.call{value: _amount}(\"\");\n        require(success, \"_transfer: ETH transfer failed\");\n    } else {\n        SafeERC20.safeTransfer(IERC20(_paymentToken), _to, _amount);\n    }\n}\n"
    },
    "@openzeppelin/contracts/token/ERC20/IERC20.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender) external view returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(address indexed owner, address indexed spender, uint256 value);\n}\n"
    },
    "@openzeppelin/contracts/utils/Address.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/Address.sol)\n\npragma solidity ^0.8.1;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary Address {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     *\n     * [IMPORTANT]\n     * ====\n     * You shouldn't rely on `isContract` to protect against flash loan attacks!\n     *\n     * Preventing calls from contracts is highly discouraged. It breaks composability, breaks support for smart wallets\n     * like Gnosis Safe, and does not provide security since it can be circumvented by calling from a contract\n     * constructor.\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize/address.code.length, which returns 0\n        // for contracts in construction, since the code is only stored at the end\n        // of the constructor execution.\n\n        return account.code.length > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionDelegateCall(target, data, \"Address: low-level delegate call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a delegate call.\n     *\n     * _Available since v3.4._\n     */\n    function functionDelegateCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(isContract(target), \"Address: delegate call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/interfaces/ILegacyOps.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\nimport {ITaskTreasuryUpgradable} from \"./ITaskTreasuryUpgradable.sol\";\n\n/**\n * @notice Legacy Ops interface with individual create task function for each task type.\n * @notice These function signatures are still supported via fallback. {See Ops.sol-fallback}\n */\ninterface ILegacyOps {\n    function createTask(\n        address _execAddress,\n        bytes4 _execSelector,\n        address _resolverAddress,\n        bytes calldata _resolverData\n    ) external returns (bytes32 taskId);\n\n    function createTaskNoPrepayment(\n        address _execAddress,\n        bytes4 _execSelector,\n        address _resolverAddress,\n        bytes calldata _resolverData,\n        address _feeToken\n    ) external returns (bytes32 taskId);\n\n    function createTimedTask(\n        uint128 _startTime,\n        uint128 _interval,\n        address _execAddress,\n        bytes4 _execSelector,\n        address _resolverAddress,\n        bytes calldata _resolverData,\n        address _feeToken,\n        bool _useTreasury\n    ) external returns (bytes32 taskId);\n\n    function cancelTask(bytes32 _taskId) external;\n\n    function exec(\n        uint256 _txFee,\n        address _feeToken,\n        address _taskCreator,\n        bool _useTaskTreasuryFunds,\n        bool _revertOnFailure,\n        bytes32 _resolverHash,\n        address _execAddress,\n        bytes calldata _execData\n    ) external;\n\n    function getFeeDetails() external view returns (uint256, address);\n\n    function getTaskIdsByUser(address _taskCreator)\n        external\n        view\n        returns (bytes32[] memory);\n\n    function taskTreasury() external view returns (ITaskTreasuryUpgradable);\n}\n"
    },
    "contracts/interfaces/IGelato1Balance.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface IGelato1Balance {\n    struct Gelato1BalanceParam {\n        address sponsor;\n        address feeToken;\n        uint256 oneBalanceChainId;\n        uint256 nativeToFeeTokenXRateNumerator;\n        uint256 nativeToFeeTokenXRateDenominator;\n        bytes32 correlationId;\n    }\n\n    event LogUseGelato1Balance(\n        address indexed sponsor,\n        address indexed target,\n        address indexed feeToken,\n        uint256 oneBalanceChainId,\n        uint256 nativeToFeeTokenXRateNumerator,\n        uint256 nativeToFeeTokenXRateDenominator,\n        bytes32 correlationId\n    );\n}\n"
    },
    "contracts/taskTreasury/TaskTreasuryUpgradable.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {\n    IERC20,\n    SafeERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {\n    ReentrancyGuardUpgradeable\n} from \"@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol\";\nimport {\n    Initializable\n} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport {_transfer, ETH} from \"../functions/FUtils.sol\";\nimport {Proxied} from \"../vendor/proxy/EIP173/Proxied.sol\";\nimport {ITaskTreasury} from \"../interfaces/ITaskTreasury.sol\";\nimport {\n    ITaskTreasuryUpgradable\n} from \"../interfaces/ITaskTreasuryUpgradable.sol\";\nimport {LibShares} from \"../libraries/LibShares.sol\";\n\ncontract TaskTreasuryUpgradable is\n    ITaskTreasuryUpgradable,\n    Proxied,\n    Initializable,\n    ReentrancyGuardUpgradeable\n{\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using SafeERC20 for IERC20;\n\n    ITaskTreasury public immutable oldTreasury;\n    uint256 public constant MIN_SHARES_IN_TREASURY = 1e12;\n    uint256 public maxFee;\n\n    ///@dev tracks token shares of users\n    mapping(address => mapping(address => uint256)) public shares;\n\n    ///@dev tracks total shares of tokens\n    mapping(address => uint256) public totalShares;\n\n    ///@dev tracks the tokens deposited by users\n    mapping(address => EnumerableSet.AddressSet) internal _tokens;\n\n    EnumerableSet.AddressSet internal _whitelistedServices;\n\n    modifier onlyWhitelistedServices() {\n        require(\n            _whitelistedServices.contains(msg.sender),\n            \"TaskTreasury: onlyWhitelistedServices\"\n        );\n        _;\n    }\n\n    constructor(ITaskTreasury _oldTreasury) {\n        oldTreasury = _oldTreasury;\n    }\n\n    receive() external payable {\n        depositFunds(msg.sender, ETH, msg.value);\n    }\n\n    function initialize(uint256 _maxFee) external initializer {\n        maxFee = _maxFee;\n        __ReentrancyGuard_init();\n    }\n\n    /// @notice Function called by whitelisted services to handle payments, e.g. Gelato Ops\n    /// @param _user Address of user whose balance will be deducted\n    /// @param _token Token to be used for payment by users\n    /// @param _amount Amount to be deducted\n    function useFunds(\n        address _user,\n        address _token,\n        uint256 _amount\n    ) external override onlyWhitelistedServices {\n        if (maxFee != 0)\n            require(maxFee >= _amount, \"TaskTreasury: Overcharged\");\n\n        uint256 balanceInOld = oldTreasury.userTokenBalance(_user, _token);\n\n        if (_amount <= balanceInOld) {\n            oldTreasury.useFunds(_token, _amount, _user);\n        } else {\n            if (balanceInOld > 0)\n                oldTreasury.useFunds(_token, balanceInOld, _user);\n\n            _pay(_user, _token, _amount - balanceInOld);\n        }\n\n        emit LogDeductFees(_user, tx.origin, _token, _amount, msg.sender);\n    }\n\n    /// @notice Change maxFee charged by Gelato (only relevant on Layer2s)\n    /// @param _newMaxFee New Max Fee to charge\n    function updateMaxFee(uint256 _newMaxFee) external override onlyProxyAdmin {\n        maxFee = _newMaxFee;\n\n        emit UpdatedMaxFee(_newMaxFee);\n    }\n\n    /// @notice Add or remove service that can call useFunds. Gelato Governance\n    /// @param _service Service to add or remove from whitelist\n    /// @param _add Add to whitelist if true, else remove from whitelist\n    function updateWhitelistedService(address _service, bool _add)\n        external\n        override\n        onlyProxyAdmin\n    {\n        if (_add) {\n            _whitelistedServices.add(_service);\n        } else {\n            _whitelistedServices.remove(_service);\n        }\n\n        emit UpdatedService(_service, _add);\n    }\n\n    /// @notice Get list of services that can call useFunds.\n    function getWhitelistedServices()\n        external\n        view\n        override\n        returns (address[] memory)\n    {\n        return _whitelistedServices.values();\n    }\n\n    // solhint-disable max-line-length\n    /// @notice Function to deposit Funds which will be used to execute transactions on various services\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function depositFunds(\n        address _receiver,\n        address _token,\n        uint256 _amount\n    ) public payable override nonReentrant {\n        uint256 depositAmount;\n        uint256 totalBalance;\n        if (_token == ETH) {\n            depositAmount = msg.value;\n        } else {\n            require(msg.value == 0, \"TaskTreasury: No ETH\");\n            IERC20 token = IERC20(_token);\n\n            uint256 preBalance = token.balanceOf(address(this));\n            token.safeTransferFrom(msg.sender, address(this), _amount);\n            uint256 postBalance = token.balanceOf(address(this));\n\n            depositAmount = postBalance - preBalance;\n        }\n\n        totalBalance = LibShares.contractBalance(_token) - depositAmount;\n\n        _creditUser(_receiver, _token, depositAmount, totalBalance);\n\n        emit FundsDeposited(_receiver, _token, depositAmount);\n    }\n\n    /// @notice Function to withdraw Funds back to the _receiver\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function withdrawFunds(\n        address payable _receiver,\n        address _token,\n        uint256 _amount\n    ) public override nonReentrant {\n        _deductUser(msg.sender, _token, _amount);\n\n        _transfer(_receiver, _token, _amount);\n\n        emit FundsWithdrawn(_receiver, msg.sender, _token, _amount);\n    }\n\n    /// @notice Helper func to get all deposited tokens by a user.\n    /// @param _user User to get the balances from\n    function getCreditTokensByUser(address _user)\n        public\n        view\n        override\n        returns (address[] memory)\n    {\n        return _tokens[_user].values();\n    }\n\n    /// @notice Helper func to get all deposited tokens by a user across treasuries.\n    /// @param _user User to get the balances from\n    function getTotalCreditTokensByUser(address _user)\n        public\n        view\n        override\n        returns (address[] memory)\n    {\n        address[] memory tokensInNew = _tokens[_user].values();\n        address[] memory tokensInOld = oldTreasury.getCreditTokensByUser(_user);\n\n        uint256 tokensInOldOnlyLength;\n        for (uint256 i; i < tokensInOld.length; i++) {\n            if (!_tokens[_user].contains(tokensInOld[i])) {\n                tokensInOld[tokensInOldOnlyLength] = tokensInOld[i];\n                tokensInOldOnlyLength++;\n            }\n        }\n\n        uint256 uniqTokensLength = tokensInNew.length + tokensInOldOnlyLength;\n        address[] memory tokens = new address[](uniqTokensLength);\n\n        for (uint256 i; i < uniqTokensLength; i++) {\n            if (i < tokensInNew.length) {\n                tokens[i] = tokensInNew[i];\n            } else {\n                uint256 j = i - tokensInNew.length;\n                tokens[i] = tokensInOld[j];\n            }\n        }\n\n        return tokens;\n    }\n\n    /// @notice Get balance of a token owned by user\n    /// @param _user User to get balance from\n    /// @param _token Token to check balance of\n    function userTokenBalance(address _user, address _token)\n        public\n        view\n        override\n        returns (uint256)\n    {\n        uint256 totalBalance = LibShares.contractBalance(_token);\n        return\n            LibShares.sharesToToken(\n                shares[_user][_token],\n                totalShares[_token],\n                totalBalance\n            );\n    }\n\n    /// @notice Get balance of a token owned by user across treasuries\n    /// @param _user User to get balance from\n    /// @param _token Token to check balance of\n    function totalUserTokenBalance(address _user, address _token)\n        public\n        view\n        override\n        returns (uint256)\n    {\n        uint256 balanceInNew = userTokenBalance(_user, _token);\n        uint256 balanceInOld = oldTreasury.userTokenBalance(_user, _token);\n\n        uint256 balance = balanceInNew + balanceInOld;\n\n        return balance;\n    }\n\n    function _creditUser(\n        address _user,\n        address _token,\n        uint256 _amount,\n        uint256 _totalBalance\n    ) internal {\n        uint256 sharesTotal = totalShares[_token];\n        uint256 sharesToCredit = LibShares.tokenToShares(\n            _token,\n            _amount,\n            sharesTotal,\n            _totalBalance\n        );\n\n        if (sharesTotal == 0)\n            require(\n                sharesToCredit >= MIN_SHARES_IN_TREASURY,\n                \"TaskTreasury: Require MIN_SHARES_IN_TREASURY\"\n            );\n\n        require(sharesToCredit > 0, \"TaskTreasury: Zero shares to credit\");\n\n        shares[_user][_token] += sharesToCredit;\n        totalShares[_token] = sharesTotal + sharesToCredit;\n\n        _tokens[_user].add(_token);\n    }\n\n    function _deductUser(\n        address _user,\n        address _token,\n        uint256 _amount\n    ) internal {\n        uint256 totalBalance = LibShares.contractBalance(_token);\n        uint256 sharesTotal = totalShares[_token];\n        uint256 sharesToCharge = LibShares.tokenToShares(\n            _token,\n            _amount,\n            sharesTotal,\n            totalBalance\n        );\n\n        require(\n            sharesTotal - sharesToCharge >= MIN_SHARES_IN_TREASURY,\n            \"TaskTreasury: Below MIN_SHARES_IN_TREASURY\"\n        );\n\n        uint256 sharesOfUser = shares[_user][_token];\n\n        shares[_user][_token] = sharesOfUser - sharesToCharge;\n        totalShares[_token] = sharesTotal - sharesToCharge;\n\n        if (sharesOfUser == sharesToCharge) _tokens[_user].remove(_token);\n    }\n\n    function _pay(\n        address _user,\n        address _token,\n        uint256 _amount\n    ) internal {\n        address admin = _proxyAdmin();\n        require(_user != admin, \"TaskTreasury: No proxy admin\");\n\n        uint256 totalBalance = LibShares.contractBalance(_token);\n        uint256 sharesToPay = LibShares.tokenToShares(\n            _token,\n            _amount,\n            totalShares[_token],\n            totalBalance\n        );\n\n        require(\n            shares[_user][_token] >= sharesToPay,\n            \"TaskTreasury: Not enough funds\"\n        );\n        shares[_user][_token] -= sharesToPay;\n        shares[admin][_token] += sharesToPay;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/security/ReentrancyGuardUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\nimport \"../proxy/utils/Initializable.sol\";\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuardUpgradeable is Initializable {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    function __ReentrancyGuard_init() internal onlyInitializing {\n        __ReentrancyGuard_init_unchained();\n    }\n\n    function __ReentrancyGuard_init_unchained() internal onlyInitializing {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n    uint256[49] private __gap;\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (proxy/utils/Initializable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../../utils/AddressUpgradeable.sol\";\n\n/**\n * @dev This is a base contract to aid in writing upgradeable contracts, or any kind of contract that will be deployed\n * behind a proxy. Since a proxied contract can't have a constructor, it's common to move constructor logic to an\n * external initializer function, usually called `initialize`. It then becomes necessary to protect this initializer\n * function so it can only be called once. The {initializer} modifier provided by this contract will have this effect.\n *\n * TIP: To avoid leaving the proxy in an uninitialized state, the initializer function should be called as early as\n * possible by providing the encoded function call as the `_data` argument to {ERC1967Proxy-constructor}.\n *\n * CAUTION: When used with inheritance, manual care must be taken to not invoke a parent initializer twice, or to ensure\n * that all initializers are idempotent. This is not verified automatically as constructors are by Solidity.\n *\n * [CAUTION]\n * ====\n * Avoid leaving a contract uninitialized.\n *\n * An uninitialized contract can be taken over by an attacker. This applies to both a proxy and its implementation\n * contract, which may impact the proxy. To initialize the implementation contract, you can either invoke the\n * initializer manually, or you can include a constructor to automatically mark it as initialized when it is deployed:\n *\n * [.hljs-theme-light.nopadding]\n * ```\n * /// @custom:oz-upgrades-unsafe-allow constructor\n * constructor() initializer {}\n * ```\n * ====\n */\nabstract contract Initializable {\n    /**\n     * @dev Indicates that the contract has been initialized.\n     */\n    bool private _initialized;\n\n    /**\n     * @dev Indicates that the contract is in the process of being initialized.\n     */\n    bool private _initializing;\n\n    /**\n     * @dev Modifier to protect an initializer function from being invoked twice.\n     */\n    modifier initializer() {\n        // If the contract is initializing we ignore whether _initialized is set in order to support multiple\n        // inheritance patterns, but we only do this in the context of a constructor, because in other contexts the\n        // contract may have been reentered.\n        require(_initializing ? _isConstructor() : !_initialized, \"Initializable: contract is already initialized\");\n\n        bool isTopLevelCall = !_initializing;\n        if (isTopLevelCall) {\n            _initializing = true;\n            _initialized = true;\n        }\n\n        _;\n\n        if (isTopLevelCall) {\n            _initializing = false;\n        }\n    }\n\n    /**\n     * @dev Modifier to protect an initialization function so that it can only be invoked by functions with the\n     * {initializer} modifier, directly or indirectly.\n     */\n    modifier onlyInitializing() {\n        require(_initializing, \"Initializable: contract is not initializing\");\n        _;\n    }\n\n    function _isConstructor() private view returns (bool) {\n        return !AddressUpgradeable.isContract(address(this));\n    }\n}\n"
    },
    "contracts/interfaces/ITaskTreasury.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\ninterface ITaskTreasury {\n    /// @notice Events ///\n    event FundsDeposited(\n        address indexed sender,\n        address indexed token,\n        uint256 indexed amount\n    );\n\n    event FundsWithdrawn(\n        address indexed receiver,\n        address indexed initiator,\n        address indexed token,\n        uint256 amount\n    );\n\n    /// @notice External functions ///\n\n    function depositFunds(\n        address receiver,\n        address token,\n        uint256 amount\n    ) external payable;\n\n    function withdrawFunds(\n        address payable receiver,\n        address token,\n        uint256 amount\n    ) external;\n\n    function useFunds(\n        address token,\n        uint256 amount,\n        address user\n    ) external;\n\n    function addWhitelistedService(address service) external;\n\n    function removeWhitelistedService(address service) external;\n\n    /// @notice External view functions ///\n\n    function gelato() external view returns (address);\n\n    function getCreditTokensByUser(address user)\n        external\n        view\n        returns (address[] memory);\n\n    function getWhitelistedServices() external view returns (address[] memory);\n\n    function userTokenBalance(address user, address token)\n        external\n        view\n        returns (uint256);\n}\n"
    },
    "contracts/libraries/LibShares.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\nimport {ETH} from \"../functions/FUtils.sol\";\nimport {IERC20Extended} from \"../interfaces/IERC20Extended.sol\";\n\nlibrary LibShares {\n    function contractBalance(address _token) internal view returns (uint256) {\n        if (_token == ETH) {\n            return address(this).balance;\n        } else {\n            return IERC20Extended(_token).balanceOf(address(this));\n        }\n    }\n\n    function tokenToShares(\n        address _token,\n        uint256 _tokenAmount,\n        uint256 _totalShares,\n        uint256 _totalBalance\n    ) internal view returns (uint256) {\n        uint256 sharesOfToken;\n\n        uint256 tokenIn18Dp = to18Dp(_token, _tokenAmount);\n        uint256 totalBalanceIn18Dp = to18Dp(_token, _totalBalance);\n\n        // credit shares equivalent to token amount\n        if (_totalShares == 0 || _totalBalance == 0) {\n            sharesOfToken = tokenIn18Dp;\n        } else {\n            sharesOfToken = divCeil(\n                tokenIn18Dp * _totalShares,\n                totalBalanceIn18Dp\n            );\n        }\n\n        return sharesOfToken;\n    }\n\n    function to18Dp(address _token, uint256 _amount)\n        internal\n        view\n        returns (uint256)\n    {\n        if (_token == ETH) return _amount;\n        uint256 decimals = IERC20Extended(_token).decimals();\n\n        if (decimals < 18) {\n            return _amount * 10**(18 - decimals);\n        } else {\n            return _amount / 10**(decimals - 18);\n        }\n    }\n\n    function sharesToToken(\n        uint256 _shares,\n        uint256 _totalShares,\n        uint256 _totalBalance\n    ) internal pure returns (uint256) {\n        uint256 tokenOfShares;\n\n        if (_totalShares == 0 || _totalBalance == 0) {\n            tokenOfShares = 0;\n        } else {\n            tokenOfShares = (_shares * _totalBalance) / _totalShares;\n        }\n\n        return tokenOfShares;\n    }\n\n    function divCeil(uint256 x, uint256 y) internal pure returns (uint256) {\n        uint256 remainder = x % y;\n        uint256 result;\n\n        if (remainder == 0) {\n            result = x / y;\n        } else {\n            result = ((x - remainder) + y) / y;\n        }\n\n        return result;\n    }\n}\n"
    },
    "@openzeppelin/contracts-upgradeable/utils/AddressUpgradeable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Address.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Collection of functions related to the address type\n */\nlibrary AddressUpgradeable {\n    /**\n     * @dev Returns true if `account` is a contract.\n     *\n     * [IMPORTANT]\n     * ====\n     * It is unsafe to assume that an address for which this function returns\n     * false is an externally-owned account (EOA) and not a contract.\n     *\n     * Among others, `isContract` will return false for the following\n     * types of addresses:\n     *\n     *  - an externally-owned account\n     *  - a contract in construction\n     *  - an address where a contract will be created\n     *  - an address where a contract lived, but was destroyed\n     * ====\n     */\n    function isContract(address account) internal view returns (bool) {\n        // This method relies on extcodesize, which returns 0 for contracts in\n        // construction, since the code is only stored at the end of the\n        // constructor execution.\n\n        uint256 size;\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n\n    /**\n     * @dev Replacement for Solidity's `transfer`: sends `amount` wei to\n     * `recipient`, forwarding all available gas and reverting on errors.\n     *\n     * https://eips.ethereum.org/EIPS/eip-1884[EIP1884] increases the gas cost\n     * of certain opcodes, possibly making contracts go over the 2300 gas limit\n     * imposed by `transfer`, making them unable to receive funds via\n     * `transfer`. {sendValue} removes this limitation.\n     *\n     * https://diligence.consensys.net/posts/2019/09/stop-using-soliditys-transfer-now/[Learn more].\n     *\n     * IMPORTANT: because control is transferred to `recipient`, care must be\n     * taken to not create reentrancy vulnerabilities. Consider using\n     * {ReentrancyGuard} or the\n     * https://solidity.readthedocs.io/en/v0.5.11/security-considerations.html#use-the-checks-effects-interactions-pattern[checks-effects-interactions pattern].\n     */\n    function sendValue(address payable recipient, uint256 amount) internal {\n        require(address(this).balance >= amount, \"Address: insufficient balance\");\n\n        (bool success, ) = recipient.call{value: amount}(\"\");\n        require(success, \"Address: unable to send value, recipient may have reverted\");\n    }\n\n    /**\n     * @dev Performs a Solidity function call using a low level `call`. A\n     * plain `call` is an unsafe replacement for a function call: use this\n     * function instead.\n     *\n     * If `target` reverts with a revert reason, it is bubbled up by this\n     * function (like regular Solidity function calls).\n     *\n     * Returns the raw returned data. To convert to the expected return value,\n     * use https://solidity.readthedocs.io/en/latest/units-and-global-variables.html?highlight=abi.decode#abi-encoding-and-decoding-functions[`abi.decode`].\n     *\n     * Requirements:\n     *\n     * - `target` must be a contract.\n     * - calling `target` with `data` must not revert.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(address target, bytes memory data) internal returns (bytes memory) {\n        return functionCall(target, data, \"Address: low-level call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`], but with\n     * `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, 0, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but also transferring `value` wei to `target`.\n     *\n     * Requirements:\n     *\n     * - the calling contract must have an ETH balance of at least `value`.\n     * - the called Solidity function must be `payable`.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value\n    ) internal returns (bytes memory) {\n        return functionCallWithValue(target, data, value, \"Address: low-level call with value failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCallWithValue-address-bytes-uint256-}[`functionCallWithValue`], but\n     * with `errorMessage` as a fallback revert reason when `target` reverts.\n     *\n     * _Available since v3.1._\n     */\n    function functionCallWithValue(\n        address target,\n        bytes memory data,\n        uint256 value,\n        string memory errorMessage\n    ) internal returns (bytes memory) {\n        require(address(this).balance >= value, \"Address: insufficient balance for call\");\n        require(isContract(target), \"Address: call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(address target, bytes memory data) internal view returns (bytes memory) {\n        return functionStaticCall(target, data, \"Address: low-level static call failed\");\n    }\n\n    /**\n     * @dev Same as {xref-Address-functionCall-address-bytes-string-}[`functionCall`],\n     * but performing a static call.\n     *\n     * _Available since v3.3._\n     */\n    function functionStaticCall(\n        address target,\n        bytes memory data,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        require(isContract(target), \"Address: static call to non-contract\");\n\n        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResult(success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verifies that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason using the provided one.\n     *\n     * _Available since v4.3._\n     */\n    function verifyCallResult(\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal pure returns (bytes memory) {\n        if (success) {\n            return returndata;\n        } else {\n            // Look for revert reason and bubble it up if present\n            if (returndata.length > 0) {\n                // The easiest way to bubble the revert reason is using memory via assembly\n\n                assembly {\n                    let returndata_size := mload(returndata)\n                    revert(add(32, returndata), returndata_size)\n                }\n            } else {\n                revert(errorMessage);\n            }\n        }\n    }\n}\n"
    },
    "contracts/interfaces/IERC20Extended.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (token/ERC20/IERC20.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20Extended {\n    function decimals() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens in existence.\n     */\n    function totalSupply() external view returns (uint256);\n\n    /**\n     * @dev Returns the amount of tokens owned by `account`.\n     */\n    function balanceOf(address account) external view returns (uint256);\n\n    /**\n     * @dev Moves `amount` tokens from the caller's account to `to`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(address to, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Returns the remaining number of tokens that `spender` will be\n     * allowed to spend on behalf of `owner` through {transferFrom}. This is\n     * zero by default.\n     *\n     * This value changes when {approve} or {transferFrom} are called.\n     */\n    function allowance(address owner, address spender)\n        external\n        view\n        returns (uint256);\n\n    /**\n     * @dev Sets `amount` as the allowance of `spender` over the caller's tokens.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * IMPORTANT: Beware that changing an allowance with this method brings the risk\n     * that someone may use both the old and the new allowance by unfortunate\n     * transaction ordering. One possible solution to mitigate this race\n     * condition is to first reduce the spender's allowance to 0 and set the\n     * desired value afterwards:\n     * https://github.com/ethereum/EIPs/issues/20#issuecomment-263524729\n     *\n     * Emits an {Approval} event.\n     */\n    function approve(address spender, uint256 amount) external returns (bool);\n\n    /**\n     * @dev Moves `amount` tokens from `from` to `to` using the\n     * allowance mechanism. `amount` is then deducted from the caller's\n     * allowance.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transferFrom(\n        address from,\n        address to,\n        uint256 amount\n    ) external returns (bool);\n\n    /**\n     * @dev Emitted when `value` tokens are moved from one account (`from`) to\n     * another (`to`).\n     *\n     * Note that `value` may be zero.\n     */\n    event Transfer(address indexed from, address indexed to, uint256 value);\n\n    /**\n     * @dev Emitted when the allowance of a `spender` for an `owner` is set by\n     * a call to {approve}. `value` is the new allowance.\n     */\n    event Approval(\n        address indexed owner,\n        address indexed spender,\n        uint256 value\n    );\n}\n"
    },
    "contracts/taskTreasury/TaskTreasuryL2.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {\n    SafeERC20,\n    IERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {\n    ReentrancyGuard\n} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {_transfer, ETH} from \"../functions/FUtils.sol\";\n\n// solhint-disable max-states-count\n// solhint-disable max-line-length\ncontract TaskTreasuryL2 is Ownable, ReentrancyGuard {\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using SafeERC20 for IERC20;\n\n    uint256 public maxFee;\n    mapping(address => mapping(address => uint256)) public userTokenBalance;\n    mapping(address => EnumerableSet.AddressSet) internal _tokenCredits;\n    EnumerableSet.AddressSet internal _whitelistedServices;\n    address payable public immutable gelato;\n\n    event FundsDeposited(\n        address indexed sender,\n        address indexed token,\n        uint256 indexed amount\n    );\n    event FundsWithdrawn(\n        address indexed receiver,\n        address indexed initiator,\n        address indexed token,\n        uint256 amount\n    );\n\n    modifier onlyWhitelistedServices() {\n        require(\n            _whitelistedServices.contains(msg.sender),\n            \"TaskTreasury: onlyWhitelistedServices\"\n        );\n        _;\n    }\n\n    constructor(address payable _gelato, uint256 _maxFee) {\n        gelato = _gelato;\n        maxFee = _maxFee;\n    }\n\n    /// @notice Function to deposit Funds which will be used to execute transactions on various services\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function depositFunds(\n        address _receiver,\n        address _token,\n        uint256 _amount\n    ) external payable {\n        uint256 depositAmount;\n        if (_token == ETH) {\n            depositAmount = msg.value;\n        } else {\n            IERC20 token = IERC20(_token);\n            uint256 preBalance = token.balanceOf(address(this));\n            token.safeTransferFrom(msg.sender, address(this), _amount);\n            uint256 postBalance = token.balanceOf(address(this));\n            depositAmount = postBalance - preBalance;\n        }\n\n        userTokenBalance[_receiver][_token] =\n            userTokenBalance[_receiver][_token] +\n            depositAmount;\n\n        if (!_tokenCredits[_receiver].contains(_token))\n            _tokenCredits[_receiver].add(_token);\n\n        emit FundsDeposited(_receiver, _token, depositAmount);\n    }\n\n    /// @notice Function to withdraw Funds back to the _receiver\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function withdrawFunds(\n        address payable _receiver,\n        address _token,\n        uint256 _amount\n    ) external nonReentrant {\n        uint256 balance = userTokenBalance[msg.sender][_token];\n\n        uint256 withdrawAmount = Math.min(balance, _amount);\n\n        userTokenBalance[msg.sender][_token] = balance - withdrawAmount;\n\n        _transfer(_receiver, _token, withdrawAmount);\n\n        if (withdrawAmount == balance) _tokenCredits[msg.sender].remove(_token);\n\n        emit FundsWithdrawn(_receiver, msg.sender, _token, withdrawAmount);\n    }\n\n    /// @notice Function called by whitelisted services to handle payments, e.g. Ops\"\n    /// @param _token Token to be used for payment by users\n    /// @param _amount Amount to be deducted\n    /// @param _user Address of user whose balance will be deducted\n    function useFunds(\n        address _token,\n        uint256 _amount,\n        address _user\n    ) external onlyWhitelistedServices {\n        if (maxFee != 0)\n            require(maxFee >= _amount, \"TaskTreasury: useFunds: Overchared\");\n        userTokenBalance[_user][_token] =\n            userTokenBalance[_user][_token] -\n            _amount;\n\n        if (userTokenBalance[_user][_token] == 0)\n            _tokenCredits[_user].remove(_token);\n\n        _transfer(gelato, _token, _amount);\n    }\n\n    // Governance functions\n\n    /// @notice Add new service that can call useFunds. Gelato Governance\n    /// @param _service New service to add\n    function addWhitelistedService(address _service) external onlyOwner {\n        require(\n            !_whitelistedServices.contains(_service),\n            \"TaskTreasury: addWhitelistedService: whitelisted\"\n        );\n        _whitelistedServices.add(_service);\n    }\n\n    /// @notice Remove old service that can call useFunds. Gelato Governance\n    /// @param _service Old service to remove\n    function removeWhitelistedService(address _service) external onlyOwner {\n        require(\n            _whitelistedServices.contains(_service),\n            \"TaskTreasury: addWhitelistedService: !whitelisted\"\n        );\n        _whitelistedServices.remove(_service);\n    }\n\n    /// @notice Change maxFee charged by Gelato (only relevant on Layer2s)\n    /// @param _newMaxFee New Max Fee to charge\n    function setMaxFee(uint256 _newMaxFee) external onlyOwner {\n        maxFee = _newMaxFee;\n    }\n\n    // View Funcs\n\n    /// @notice Helper func to get all deposited tokens by a user\n    /// @param _user User to get the balances from\n    function getCreditTokensByUser(address _user)\n        external\n        view\n        returns (address[] memory)\n    {\n        uint256 length = _tokenCredits[_user].length();\n        address[] memory creditTokens = new address[](length);\n\n        for (uint256 i; i < length; i++) {\n            creditTokens[i] = _tokenCredits[_user].at(i);\n        }\n        return creditTokens;\n    }\n\n    function getWhitelistedServices() external view returns (address[] memory) {\n        uint256 length = _whitelistedServices.length();\n        address[] memory whitelistedServices = new address[](length);\n\n        for (uint256 i; i < length; i++) {\n            whitelistedServices[i] = _whitelistedServices.at(i);\n        }\n        return whitelistedServices;\n    }\n}\n"
    },
    "@openzeppelin/contracts/access/Ownable.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (access/Ownable.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../utils/Context.sol\";\n\n/**\n * @dev Contract module which provides a basic access control mechanism, where\n * there is an account (an owner) that can be granted exclusive access to\n * specific functions.\n *\n * By default, the owner account will be the one that deploys the contract. This\n * can later be changed with {transferOwnership}.\n *\n * This module is used through inheritance. It will make available the modifier\n * `onlyOwner`, which can be applied to your functions to restrict their use to\n * the owner.\n */\nabstract contract Ownable is Context {\n    address private _owner;\n\n    event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);\n\n    /**\n     * @dev Initializes the contract setting the deployer as the initial owner.\n     */\n    constructor() {\n        _transferOwnership(_msgSender());\n    }\n\n    /**\n     * @dev Returns the address of the current owner.\n     */\n    function owner() public view virtual returns (address) {\n        return _owner;\n    }\n\n    /**\n     * @dev Throws if called by any account other than the owner.\n     */\n    modifier onlyOwner() {\n        require(owner() == _msgSender(), \"Ownable: caller is not the owner\");\n        _;\n    }\n\n    /**\n     * @dev Leaves the contract without owner. It will not be possible to call\n     * `onlyOwner` functions anymore. Can only be called by the current owner.\n     *\n     * NOTE: Renouncing ownership will leave the contract without an owner,\n     * thereby removing any functionality that is only available to the owner.\n     */\n    function renounceOwnership() public virtual onlyOwner {\n        _transferOwnership(address(0));\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Can only be called by the current owner.\n     */\n    function transferOwnership(address newOwner) public virtual onlyOwner {\n        require(newOwner != address(0), \"Ownable: new owner is the zero address\");\n        _transferOwnership(newOwner);\n    }\n\n    /**\n     * @dev Transfers ownership of the contract to a new account (`newOwner`).\n     * Internal function without access restriction.\n     */\n    function _transferOwnership(address newOwner) internal virtual {\n        address oldOwner = _owner;\n        _owner = newOwner;\n        emit OwnershipTransferred(oldOwner, newOwner);\n    }\n}\n"
    },
    "@openzeppelin/contracts/security/ReentrancyGuard.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (security/ReentrancyGuard.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Contract module that helps prevent reentrant calls to a function.\n *\n * Inheriting from `ReentrancyGuard` will make the {nonReentrant} modifier\n * available, which can be applied to functions to make sure there are no nested\n * (reentrant) calls to them.\n *\n * Note that because there is a single `nonReentrant` guard, functions marked as\n * `nonReentrant` may not call one another. This can be worked around by making\n * those functions `private`, and then adding `external` `nonReentrant` entry\n * points to them.\n *\n * TIP: If you would like to learn more about reentrancy and alternative ways\n * to protect against it, check out our blog post\n * https://blog.openzeppelin.com/reentrancy-after-istanbul/[Reentrancy After Istanbul].\n */\nabstract contract ReentrancyGuard {\n    // Booleans are more expensive than uint256 or any type that takes up a full\n    // word because each write operation emits an extra SLOAD to first read the\n    // slot's contents, replace the bits taken up by the boolean, and then write\n    // back. This is the compiler's defense against contract upgrades and\n    // pointer aliasing, and it cannot be disabled.\n\n    // The values being non-zero value makes deployment a bit more expensive,\n    // but in exchange the refund on every call to nonReentrant will be lower in\n    // amount. Since refunds are capped to a percentage of the total\n    // transaction's gas, it is best to keep them low in cases like this one, to\n    // increase the likelihood of the full refund coming into effect.\n    uint256 private constant _NOT_ENTERED = 1;\n    uint256 private constant _ENTERED = 2;\n\n    uint256 private _status;\n\n    constructor() {\n        _status = _NOT_ENTERED;\n    }\n\n    /**\n     * @dev Prevents a contract from calling itself, directly or indirectly.\n     * Calling a `nonReentrant` function from another `nonReentrant`\n     * function is not supported. It is possible to prevent this from happening\n     * by making the `nonReentrant` function external, and making it call a\n     * `private` function that does the actual work.\n     */\n    modifier nonReentrant() {\n        // On the first call to nonReentrant, _notEntered will be true\n        require(_status != _ENTERED, \"ReentrancyGuard: reentrant call\");\n\n        // Any calls to nonReentrant after this point will fail\n        _status = _ENTERED;\n\n        _;\n\n        // By storing the original value once again, a refund is triggered (see\n        // https://eips.ethereum.org/EIPS/eip-2200)\n        _status = _NOT_ENTERED;\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/math/Math.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.5.0) (utils/math/Math.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Standard math utilities missing in the Solidity language.\n */\nlibrary Math {\n    /**\n     * @dev Returns the largest of two numbers.\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n\n    /**\n     * @dev Returns the smallest of two numbers.\n     */\n    function min(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a < b ? a : b;\n    }\n\n    /**\n     * @dev Returns the average of two numbers. The result is rounded towards\n     * zero.\n     */\n    function average(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b) / 2 can overflow.\n        return (a & b) + (a ^ b) / 2;\n    }\n\n    /**\n     * @dev Returns the ceiling of the division of two numbers.\n     *\n     * This differs from standard division with `/` in that it rounds up instead\n     * of rounding down.\n     */\n    function ceilDiv(uint256 a, uint256 b) internal pure returns (uint256) {\n        // (a + b - 1) / b can overflow on addition, so we distribute.\n        return a / b + (a % b == 0 ? 0 : 1);\n    }\n}\n"
    },
    "@openzeppelin/contracts/utils/Context.sol": {
      "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (utils/Context.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Provides information about the current execution context, including the\n * sender of the transaction and its data. While these are generally available\n * via msg.sender and msg.data, they should not be accessed in such a direct\n * manner, since when dealing with meta-transactions the account sending and\n * paying for execution may not be the actual sender (as far as an application\n * is concerned).\n *\n * This contract is only required for intermediate, library-like contracts.\n */\nabstract contract Context {\n    function _msgSender() internal view virtual returns (address) {\n        return msg.sender;\n    }\n\n    function _msgData() internal view virtual returns (bytes calldata) {\n        return msg.data;\n    }\n}\n"
    },
    "contracts/taskTreasury/TaskTreasury.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {\n    EnumerableSet\n} from \"@openzeppelin/contracts/utils/structs/EnumerableSet.sol\";\nimport {\n    SafeERC20,\n    IERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\nimport {\n    ReentrancyGuard\n} from \"@openzeppelin/contracts/security/ReentrancyGuard.sol\";\nimport {Math} from \"@openzeppelin/contracts/utils/math/Math.sol\";\nimport {_transfer, ETH} from \"../functions/FUtils.sol\";\n\ncontract TaskTreasury is Ownable, ReentrancyGuard {\n    using EnumerableSet for EnumerableSet.AddressSet;\n    using SafeERC20 for IERC20;\n\n    mapping(address => mapping(address => uint256)) public userTokenBalance;\n    mapping(address => EnumerableSet.AddressSet) internal _tokenCredits;\n    EnumerableSet.AddressSet internal _whitelistedServices;\n    address payable public immutable gelato;\n\n    event FundsDeposited(\n        address indexed sender,\n        address indexed token,\n        uint256 indexed amount\n    );\n    event FundsWithdrawn(\n        address indexed receiver,\n        address indexed initiator,\n        address indexed token,\n        uint256 amount\n    );\n\n    modifier onlyWhitelistedServices() {\n        require(\n            _whitelistedServices.contains(msg.sender),\n            \"TaskTreasury: onlyWhitelistedServices\"\n        );\n        _;\n    }\n\n    constructor(address payable _gelato) {\n        gelato = _gelato;\n    }\n\n    // solhint-disable max-line-length\n    /// @notice Function to deposit Funds which will be used to execute transactions on various services\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function depositFunds(\n        address _receiver,\n        address _token,\n        uint256 _amount\n    ) external payable {\n        uint256 depositAmount;\n        if (_token == ETH) {\n            depositAmount = msg.value;\n        } else {\n            IERC20 token = IERC20(_token);\n            uint256 preBalance = token.balanceOf(address(this));\n            token.safeTransferFrom(msg.sender, address(this), _amount);\n            uint256 postBalance = token.balanceOf(address(this));\n            depositAmount = postBalance - preBalance;\n        }\n\n        userTokenBalance[_receiver][_token] =\n            userTokenBalance[_receiver][_token] +\n            depositAmount;\n\n        if (!_tokenCredits[_receiver].contains(_token))\n            _tokenCredits[_receiver].add(_token);\n\n        emit FundsDeposited(_receiver, _token, depositAmount);\n    }\n\n    /// @notice Function to withdraw Funds back to the _receiver\n    /// @param _receiver Address receiving the credits\n    /// @param _token Token to be credited, use \"0xeeee....\" for ETH\n    /// @param _amount Amount to be credited\n    function withdrawFunds(\n        address payable _receiver,\n        address _token,\n        uint256 _amount\n    ) external nonReentrant {\n        uint256 balance = userTokenBalance[msg.sender][_token];\n\n        uint256 withdrawAmount = Math.min(balance, _amount);\n\n        userTokenBalance[msg.sender][_token] = balance - withdrawAmount;\n\n        _transfer(_receiver, _token, withdrawAmount);\n\n        if (withdrawAmount == balance) _tokenCredits[msg.sender].remove(_token);\n\n        emit FundsWithdrawn(_receiver, msg.sender, _token, withdrawAmount);\n    }\n\n    /// @notice Function called by whitelisted services to handle payments, e.g. Ops\"\n    /// @param _token Token to be used for payment by users\n    /// @param _amount Amount to be deducted\n    /// @param _user Address of user whose balance will be deducted\n    function useFunds(\n        address _token,\n        uint256 _amount,\n        address _user\n    ) external onlyWhitelistedServices {\n        userTokenBalance[_user][_token] =\n            userTokenBalance[_user][_token] -\n            _amount;\n\n        if (userTokenBalance[_user][_token] == 0)\n            _tokenCredits[_user].remove(_token);\n\n        _transfer(gelato, _token, _amount);\n    }\n\n    // Governance functions\n\n    /// @notice Add new service that can call useFunds. Gelato Governance\n    /// @param _service New service to add\n    function addWhitelistedService(address _service) external onlyOwner {\n        require(\n            !_whitelistedServices.contains(_service),\n            \"TaskTreasury: addWhitelistedService: whitelisted\"\n        );\n        _whitelistedServices.add(_service);\n    }\n\n    /// @notice Remove old service that can call useFunds. Gelato Governance\n    /// @param _service Old service to remove\n    function removeWhitelistedService(address _service) external onlyOwner {\n        require(\n            _whitelistedServices.contains(_service),\n            \"TaskTreasury: addWhitelistedService: !whitelisted\"\n        );\n        _whitelistedServices.remove(_service);\n    }\n\n    // View Funcs\n\n    /// @notice Helper func to get all deposited tokens by a user\n    /// @param _user User to get the balances from\n    function getCreditTokensByUser(address _user)\n        external\n        view\n        returns (address[] memory)\n    {\n        uint256 length = _tokenCredits[_user].length();\n        address[] memory creditTokens = new address[](length);\n\n        for (uint256 i; i < length; i++) {\n            creditTokens[i] = _tokenCredits[_user].at(i);\n        }\n        return creditTokens;\n    }\n\n    function getWhitelistedServices() external view returns (address[] memory) {\n        uint256 length = _whitelistedServices.length();\n        address[] memory whitelistedServices = new address[](length);\n\n        for (uint256 i; i < length; i++) {\n            whitelistedServices[i] = _whitelistedServices.at(i);\n        }\n        return whitelistedServices;\n    }\n}\n"
    },
    "contracts/tests/CounterWL.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {Ownable} from \"@openzeppelin/contracts/access/Ownable.sol\";\n\n// solhint-disable not-rely-on-time\ncontract CounterWL is Ownable {\n    uint256 public count;\n    uint256 public lastExecuted;\n    mapping(address => bool) public whitelisted;\n\n    modifier onlyWhitelisted() {\n        require(\n            whitelisted[msg.sender] || msg.sender == owner(),\n            \"Counter: Not whitelisted\"\n        );\n        _;\n    }\n\n    function increaseCount(uint256 amount) external onlyWhitelisted {\n        require(\n            ((block.timestamp - lastExecuted) > 180),\n            \"Counter: increaseCount: Time not elapsed\"\n        );\n\n        count += amount;\n        lastExecuted = block.timestamp;\n    }\n\n    function setWhitelist(address _account, bool _whitelist)\n        external\n        onlyOwner\n    {\n        whitelisted[_account] = _whitelist;\n    }\n}\n"
    },
    "contracts/vendor/gelato/OpsReady.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    SafeERC20,\n    IERC20\n} from \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\ninterface IOps {\n    function gelato() external view returns (address payable);\n}\n\nabstract contract OpsReady {\n    address public immutable ops;\n    address payable public immutable gelato;\n    address public constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n\n    modifier onlyOps() {\n        require(msg.sender == ops, \"OpsReady: onlyOps\");\n        _;\n    }\n\n    constructor(address _ops) {\n        ops = _ops;\n        gelato = IOps(_ops).gelato();\n    }\n\n    function _transfer(uint256 _amount, address _paymentToken) internal {\n        if (_paymentToken == ETH) {\n            (bool success, ) = gelato.call{value: _amount}(\"\");\n            require(success, \"_transfer: ETH transfer failed\");\n        } else {\n            SafeERC20.safeTransfer(IERC20(_paymentToken), gelato, _amount);\n        }\n    }\n}\n"
    },
    "contracts/integrations/OpsReady.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport \"./Types.sol\";\n\n/**\n * @dev Inherit this contract to allow your smart contract to\n * - Make synchronous fee payments.\n * - Have call restrictions for functions to be automated.\n */\n// solhint-disable private-vars-leading-underscore\nabstract contract OpsReady {\n    IOps public immutable ops;\n    address public immutable dedicatedMsgSender;\n    address private immutable _gelato;\n    address internal constant ETH = 0xEeeeeEeeeEeEeeEeEeEeeEEEeeeeEeeeeeeeEEeE;\n    address private constant OPS_PROXY_FACTORY =\n        0xC815dB16D4be6ddf2685C201937905aBf338F5D7;\n\n    /**\n     * @dev\n     * Only tasks created by _taskCreator defined in constructor can call\n     * the functions with this modifier.\n     */\n    modifier onlyDedicatedMsgSender() {\n        require(msg.sender == dedicatedMsgSender, \"Only dedicated msg.sender\");\n        _;\n    }\n\n    /**\n     * @dev\n     * _taskCreator is the address which will create tasks for this contract.\n     */\n    constructor(address _ops, address _taskCreator) {\n        ops = IOps(_ops);\n        _gelato = IOps(_ops).gelato();\n        (dedicatedMsgSender, ) = IOpsProxyFactory(OPS_PROXY_FACTORY).getProxyOf(\n            _taskCreator\n        );\n    }\n\n    /**\n     * @dev\n     * Transfers fee to gelato for synchronous fee payments.\n     *\n     * _fee & _feeToken should be queried from IOps.getFeeDetails()\n     */\n    function _transfer(uint256 _fee, address _feeToken) internal {\n        if (_feeToken == ETH) {\n            (bool success, ) = _gelato.call{value: _fee}(\"\");\n            require(success, \"_transfer: ETH transfer failed\");\n        } else {\n            SafeERC20.safeTransfer(IERC20(_feeToken), _gelato, _fee);\n        }\n    }\n\n    function _getFeeDetails()\n        internal\n        view\n        returns (uint256 fee, address feeToken)\n    {\n        (fee, feeToken) = ops.getFeeDetails();\n    }\n}\n"
    },
    "contracts/integrations/Types.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nenum Module {\n    RESOLVER,\n    TIME,\n    PROXY,\n    SINGLE_EXEC\n}\n\nstruct ModuleData {\n    Module[] modules;\n    bytes[] args;\n}\n\ninterface IOps {\n    function createTask(\n        address execAddress,\n        bytes calldata execDataOrSelector,\n        ModuleData calldata moduleData,\n        address feeToken\n    ) external returns (bytes32 taskId);\n\n    function cancelTask(bytes32 taskId) external;\n\n    function getFeeDetails() external view returns (uint256, address);\n\n    function gelato() external view returns (address payable);\n\n    function taskTreasury() external view returns (ITaskTreasuryUpgradable);\n}\n\ninterface ITaskTreasuryUpgradable {\n    function depositFunds(\n        address receiver,\n        address token,\n        uint256 amount\n    ) external payable;\n\n    function withdrawFunds(\n        address payable receiver,\n        address token,\n        uint256 amount\n    ) external;\n}\n\ninterface IOpsProxyFactory {\n    function getProxyOf(address account) external view returns (address, bool);\n}\n"
    },
    "contracts/tests/CounterTestWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../integrations/OpsReady.sol\";\n\n// solhint-disable no-empty-blocks\n// solhint-disable not-rely-on-time\ncontract CounterTestWT is OpsReady {\n    uint256 public count;\n    uint256 public lastExecuted;\n\n    constructor(address _ops, address _taskCreator)\n        OpsReady(_ops, _taskCreator)\n    {}\n\n    receive() external payable {}\n\n    function increaseCount(uint256 amount) external {\n        require(\n            ((block.timestamp - lastExecuted) > 180),\n            \"Counter: increaseCount: Time not elapsed\"\n        );\n\n        count += amount;\n        lastExecuted = block.timestamp;\n\n        (uint256 fee, address feeToken) = _getFeeDetails();\n\n        _transfer(fee, feeToken);\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        canExec = (block.timestamp - lastExecuted) > 180;\n\n        execPayload = abi.encodeCall(this.increaseCount, (1));\n    }\n}\n"
    },
    "contracts/integrations/examples/userCreator/withTreasury/Counter.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {OpsReady} from \"../../../OpsReady.sol\";\n\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract Counter is OpsReady {\n    uint256 public count;\n    uint256 public lastExecuted;\n\n    constructor(address payable _ops, address _taskCreator)\n        OpsReady(_ops, _taskCreator)\n    {}\n\n    function increaseCount(uint256 amount) external onlyDedicatedMsgSender {\n        count += amount;\n        lastExecuted = block.timestamp;\n    }\n}\n"
    },
    "contracts/integrations/examples/userCreator/withoutTreasury/CounterWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport {OpsReady} from \"../../../OpsReady.sol\";\n\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterWT is OpsReady {\n    uint256 public count;\n    uint256 public lastExecuted;\n\n    constructor(address _ops, address _taskCreator)\n        OpsReady(_ops, _taskCreator)\n    {}\n\n    receive() external payable {}\n\n    function increaseCount(uint256 amount) external onlyDedicatedMsgSender {\n        count += amount;\n        lastExecuted = block.timestamp;\n\n        (uint256 fee, address feeToken) = _getFeeDetails();\n\n        _transfer(fee, feeToken);\n    }\n}\n"
    },
    "contracts/integrations/OpsTaskCreator.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.14;\n\nimport \"./OpsReady.sol\";\n\n/**\n * @dev Inherit this contract to allow your smart contract\n * to be a task creator and create tasks.\n */\nabstract contract OpsTaskCreator is OpsReady {\n    using SafeERC20 for IERC20;\n\n    address public immutable fundsOwner;\n    ITaskTreasuryUpgradable public immutable taskTreasury;\n\n    constructor(address _ops, address _fundsOwner)\n        OpsReady(_ops, address(this))\n    {\n        fundsOwner = _fundsOwner;\n        taskTreasury = ops.taskTreasury();\n    }\n\n    /**\n     * @dev\n     * Withdraw funds from this contract's Gelato balance to fundsOwner.\n     */\n    function withdrawFunds(uint256 _amount, address _token) external {\n        require(\n            msg.sender == fundsOwner,\n            \"Only funds owner can withdraw funds\"\n        );\n\n        taskTreasury.withdrawFunds(payable(fundsOwner), _token, _amount);\n    }\n\n    function _depositFunds(uint256 _amount, address _token) internal {\n        uint256 ethValue = _token == ETH ? _amount : 0;\n        taskTreasury.depositFunds{value: ethValue}(\n            address(this),\n            _token,\n            _amount\n        );\n    }\n\n    function _createTask(\n        address _execAddress,\n        bytes memory _execDataOrSelector,\n        ModuleData memory _moduleData,\n        address _feeToken\n    ) internal returns (bytes32) {\n        return\n            ops.createTask(\n                _execAddress,\n                _execDataOrSelector,\n                _moduleData,\n                _feeToken\n            );\n    }\n\n    function _cancelTask(bytes32 _taskId) internal {\n        ops.cancelTask(_taskId);\n    }\n\n    function _resolverModuleArg(\n        address _resolverAddress,\n        bytes memory _resolverData\n    ) internal pure returns (bytes memory) {\n        return abi.encode(_resolverAddress, _resolverData);\n    }\n\n    function _timeModuleArg(uint256 _startTime, uint256 _interval)\n        internal\n        pure\n        returns (bytes memory)\n    {\n        return abi.encode(uint128(_startTime), uint128(_interval));\n    }\n\n    function _proxyModuleArg() internal pure returns (bytes memory) {\n        return bytes(\"\");\n    }\n\n    function _singleExecModuleArg() internal pure returns (bytes memory) {\n        return bytes(\"\");\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withTreasury/CounterTimeTaskCreator.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a time task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterTimeTaskCreator is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    function createTask() external {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        bytes memory execData = abi.encodeCall(this.increaseCount, (1));\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n        moduleData.modules[0] = Module.TIME;\n        moduleData.modules[1] = Module.PROXY;\n\n        moduleData.args[0] = _timeModuleArg(block.timestamp, INTERVAL);\n        moduleData.args[1] = _proxyModuleArg();\n\n        bytes32 id = _createTask(\n            address(this),\n            execData,\n            moduleData,\n            address(0)\n        );\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        uint256 newCount = count + _amount;\n\n        if (newCount >= MAX_COUNT) {\n            _cancelTask(taskId);\n            count = 0;\n        } else {\n            count += _amount;\n            lastExecuted = block.timestamp;\n        }\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withTreasury/CounterSingleExecTaskCreator.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a single exec task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterSingleExecTaskCreator is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    function createTask() external {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        bytes memory execData = abi.encodeCall(this.increaseCount, (1));\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n        moduleData.modules[0] = Module.PROXY;\n        moduleData.modules[1] = Module.SINGLE_EXEC;\n\n        moduleData.args[0] = _proxyModuleArg();\n        moduleData.args[1] = _singleExecModuleArg();\n\n        bytes32 id = _createTask(\n            address(this),\n            execData,\n            moduleData,\n            address(0)\n        );\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        count += _amount;\n        taskId = bytes32(\"\");\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withTreasury/CounterResolverTaskCreator.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a resolver task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterResolverTaskCreator is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    function createTask() external {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n\n        moduleData.modules[0] = Module.RESOLVER;\n        moduleData.modules[1] = Module.PROXY;\n\n        moduleData.args[0] = _resolverModuleArg(\n            address(this),\n            abi.encodeCall(this.checker, ())\n        );\n        moduleData.args[1] = _proxyModuleArg();\n\n        bytes32 id = _createTask(\n            address(this),\n            abi.encode(this.increaseCount.selector),\n            moduleData,\n            address(0)\n        );\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        uint256 newCount = count + _amount;\n\n        if (newCount >= MAX_COUNT) {\n            _cancelTask(taskId);\n            count = 0;\n        } else {\n            count += _amount;\n            lastExecuted = block.timestamp;\n        }\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        canExec = (block.timestamp - lastExecuted) >= INTERVAL;\n\n        execPayload = abi.encodeCall(this.increaseCount, (1));\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withoutTreasury/CounterTimeTaskCreatorWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a time task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterTimeTaskCreatorWT is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address payable _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    receive() external payable {}\n\n    function createTask() external payable {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        bytes memory execData = abi.encodeCall(this.increaseCount, (1));\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n        moduleData.modules[0] = Module.TIME;\n        moduleData.modules[1] = Module.PROXY;\n\n        moduleData.args[0] = _timeModuleArg(block.timestamp, INTERVAL);\n        moduleData.args[1] = _proxyModuleArg();\n\n        bytes32 id = _createTask(address(this), execData, moduleData, ETH);\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        uint256 newCount = count + _amount;\n\n        if (newCount >= MAX_COUNT) {\n            _cancelTask(taskId);\n            count = 0;\n        } else {\n            count += _amount;\n            lastExecuted = block.timestamp;\n        }\n\n        (uint256 fee, address feeToken) = _getFeeDetails();\n\n        _transfer(fee, feeToken);\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withoutTreasury/CounterSingleExecTaskCreatorWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a single exec task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterSingleExecTaskCreatorWT is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address payable _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    receive() external payable {}\n\n    function createTask() external payable {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        bytes memory execData = abi.encodeCall(this.increaseCount, (1));\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n\n        moduleData.modules[0] = Module.PROXY;\n        moduleData.modules[1] = Module.SINGLE_EXEC;\n\n        moduleData.args[0] = _proxyModuleArg();\n        moduleData.args[1] = _singleExecModuleArg();\n\n        bytes32 id = _createTask(address(this), execData, moduleData, ETH);\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        count += _amount;\n        taskId = bytes32(\"\");\n\n        (uint256 fee, address feeToken) = _getFeeDetails();\n\n        _transfer(fee, feeToken);\n    }\n}\n"
    },
    "contracts/integrations/examples/contractCreator/withoutTreasury/CounterResolverTaskCreatorWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\nimport \"../../../OpsTaskCreator.sol\";\n\n/**\n * @dev\n * Example contract that creates a resolver task.\n */\n// solhint-disable not-rely-on-time\n// solhint-disable no-empty-blocks\ncontract CounterResolverTaskCreatorWT is OpsTaskCreator {\n    uint256 public count;\n    uint256 public lastExecuted;\n    bytes32 public taskId;\n    uint256 public constant MAX_COUNT = 5;\n    uint256 public constant INTERVAL = 3 minutes;\n\n    event CounterTaskCreated(bytes32 taskId);\n\n    constructor(address payable _ops, address _fundsOwner)\n        OpsTaskCreator(_ops, _fundsOwner)\n    {}\n\n    receive() external payable {}\n\n    function createTask() external payable {\n        require(taskId == bytes32(\"\"), \"Already started task\");\n\n        ModuleData memory moduleData = ModuleData({\n            modules: new Module[](2),\n            args: new bytes[](2)\n        });\n\n        moduleData.modules[0] = Module.RESOLVER;\n        moduleData.modules[1] = Module.PROXY;\n\n        moduleData.args[0] = _resolverModuleArg(\n            address(this),\n            abi.encodeCall(this.checker, ())\n        );\n        moduleData.args[1] = _proxyModuleArg();\n\n        bytes32 id = _createTask(\n            address(this),\n            abi.encode(this.increaseCount.selector),\n            moduleData,\n            ETH\n        );\n\n        taskId = id;\n        emit CounterTaskCreated(id);\n    }\n\n    function increaseCount(uint256 _amount) external onlyDedicatedMsgSender {\n        uint256 newCount = count + _amount;\n\n        if (newCount >= MAX_COUNT) {\n            _cancelTask(taskId);\n            count = 0;\n        } else {\n            count += _amount;\n            lastExecuted = block.timestamp;\n        }\n\n        (uint256 fee, address feeToken) = _getFeeDetails();\n\n        _transfer(fee, feeToken);\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        canExec = (block.timestamp - lastExecuted) >= INTERVAL;\n\n        execPayload = abi.encodeCall(this.increaseCount, (1));\n    }\n}\n"
    },
    "contracts/opsProxy/OpsProxyFactory.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {\n    Initializable\n} from \"@openzeppelin/contracts-upgradeable/proxy/utils/Initializable.sol\";\nimport {EIP173OpsProxy} from \"../vendor/proxy/EIP173/EIP173OpsProxy.sol\";\nimport {Proxied} from \"../vendor/proxy/EIP173/Proxied.sol\";\nimport {IOpsProxyFactory} from \"../interfaces/IOpsProxyFactory.sol\";\n\n// solhint-disable max-states-count\ncontract OpsProxyFactory is Initializable, Proxied, IOpsProxyFactory {\n    address public immutable ops;\n    address public implementation;\n    mapping(address => bool) public override whitelistedImplementations;\n\n    ///@dev track proxy of user\n    mapping(address => address) internal _proxyOf;\n\n    ///@dev track owner of proxy\n    mapping(address => address) internal _ownerOf;\n\n    modifier onlyOneProxy(address _account) {\n        require(_proxyOf[_account] == address(0), \"OpsProxyFactory: One proxy\");\n        _;\n    }\n\n    modifier notProxy(address _account) {\n        require(_ownerOf[_account] == address(0), \"OpsProxyFactory: No proxy\");\n        _;\n    }\n\n    constructor(address _ops) {\n        ops = _ops;\n    }\n\n    function initialize(address _implementation) external initializer {\n        implementation = _implementation;\n        whitelistedImplementations[_implementation] = true;\n    }\n\n    ///@inheritdoc IOpsProxyFactory\n    function deploy() external override returns (address payable proxy) {\n        proxy = deployFor(msg.sender);\n    }\n\n    function setImplementation(address _newImplementation)\n        external\n        onlyProxyAdmin\n    {\n        address oldImplementation = implementation;\n        require(\n            oldImplementation != _newImplementation &&\n                whitelistedImplementations[_newImplementation],\n            \"OpsProxyFactory: Invalid implementation\"\n        );\n\n        implementation = _newImplementation;\n\n        emit SetImplementation(oldImplementation, _newImplementation);\n    }\n\n    function updateWhitelistedImplementations(\n        address _implementation,\n        bool _whitelist\n    ) external onlyProxyAdmin {\n        whitelistedImplementations[_implementation] = _whitelist;\n\n        emit UpdateWhitelistedImplementation(_implementation, _whitelist);\n    }\n\n    ///@inheritdoc IOpsProxyFactory\n    function getProxyOf(address _account)\n        external\n        view\n        override\n        returns (address, bool)\n    {\n        address proxyAddress = _proxyOf[_account];\n\n        if (proxyAddress != address(0)) return (proxyAddress, true);\n\n        proxyAddress = determineProxyAddress(_account);\n        return (proxyAddress, false);\n    }\n\n    ///@inheritdoc IOpsProxyFactory\n    function ownerOf(address _proxy) external view override returns (address) {\n        return _ownerOf[_proxy];\n    }\n\n    ///@inheritdoc IOpsProxyFactory\n    function deployFor(address owner)\n        public\n        override\n        onlyOneProxy(owner)\n        notProxy(owner)\n        returns (address payable proxy)\n    {\n        proxy = _deploy(bytes32(0), _getBytecode(owner));\n\n        _proxyOf[owner] = proxy;\n        _ownerOf[proxy] = owner;\n\n        emit DeployProxy(msg.sender, owner, address(proxy));\n    }\n\n    ///@inheritdoc IOpsProxyFactory\n    function determineProxyAddress(address _account)\n        public\n        view\n        override\n        returns (address)\n    {\n        address proxyAddress = _proxyOf[_account];\n        if (proxyAddress != address(0)) return proxyAddress;\n\n        bytes memory bytecode = _getBytecode(_account);\n\n        bytes32 codeHash = keccak256(\n            abi.encodePacked(\n                bytes1(0xff),\n                address(this),\n                bytes32(0),\n                keccak256(bytecode)\n            )\n        );\n\n        return address(uint160(uint256(codeHash)));\n    }\n\n    function _deploy(bytes32 _salt, bytes memory _bytecode)\n        internal\n        returns (address payable proxy)\n    {\n        assembly {\n            let endowment := 0\n            let bytecodeStart := add(_bytecode, 0x20)\n            let bytecodeLength := mload(_bytecode)\n            proxy := create2(endowment, bytecodeStart, bytecodeLength, _salt)\n        }\n    }\n\n    function _getBytecode(address _owner) internal view returns (bytes memory) {\n        return\n            abi.encodePacked(\n                type(EIP173OpsProxy).creationCode,\n                abi.encode(address(this), implementation, _owner, bytes(\"\"))\n            );\n    }\n}\n"
    },
    "contracts/vendor/proxy/EIP173/EIP173OpsProxy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./Proxy.sol\";\nimport {IOpsProxyFactory} from \"../../../interfaces/IOpsProxyFactory.sol\";\n\ninterface ERC165 {\n    function supportsInterface(bytes4 id) external view returns (bool);\n}\n\n/**\n * @notice Proxy implementing EIP173 for ownership management.\n * @notice This is used for OpsProxy.\n *\n * @dev 1. custom receive can be set in implementation.\n * @dev 2. transferProxyAdmin removed.\n * @dev 3. implementation can only be set to those whitelisted on OpsProxyFactory.\n */\ncontract EIP173OpsProxy is Proxy {\n    // ////////////////////////// STATES ///////////////////////////////////////////////////////////////////////\n    IOpsProxyFactory public immutable opsProxyFactory;\n\n    // ////////////////////////// EVENTS ///////////////////////////////////////////////////////////////////////\n\n    event ProxyAdminTransferred(\n        address indexed previousAdmin,\n        address indexed newAdmin\n    );\n\n    // /////////////////////// MODIFIERS //////////////////////////////////////////////////////////////////////\n    modifier onlyWhitelistedImplementation(address _implementation) {\n        require(\n            opsProxyFactory.whitelistedImplementations(_implementation),\n            \"Implementation not whitelisted\"\n        );\n        _;\n    }\n\n    // /////////////////////// FALLBACKS //////////////////////////////////////////////////////////////////////\n    receive() external payable override {\n        _fallback();\n    }\n\n    // /////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////////////\n\n    constructor(\n        address _opsProxyFactory,\n        address implementationAddress,\n        address adminAddress,\n        bytes memory data\n    ) payable {\n        opsProxyFactory = IOpsProxyFactory(_opsProxyFactory);\n        _setImplementation(implementationAddress, data);\n        _setProxyAdmin(adminAddress);\n    }\n\n    // ///////////////////// EXTERNAL ///////////////////////////////////////////////////////////////////////////\n\n    function proxyAdmin() external view returns (address) {\n        return _proxyAdmin();\n    }\n\n    function supportsInterface(bytes4 id) external view returns (bool) {\n        if (id == 0x01ffc9a7 || id == 0x7f5828d0) {\n            return true;\n        }\n        if (id == 0xFFFFFFFF) {\n            return false;\n        }\n\n        ERC165 implementation;\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            implementation := sload(\n                0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n            )\n        }\n\n        // Technically this is not standard compliant as ERC-165 require 30,000 gas which that call cannot ensure\n        // because it is itself inside `supportsInterface` that might only get 30,000 gas.\n        // In practise this is unlikely to be an issue.\n        try implementation.supportsInterface(id) returns (bool support) {\n            return support;\n        } catch {\n            return false;\n        }\n    }\n\n    function upgradeTo(address newImplementation)\n        external\n        onlyProxyAdmin\n        onlyWhitelistedImplementation(newImplementation)\n    {\n        _setImplementation(newImplementation, \"\");\n    }\n\n    function upgradeToAndCall(address newImplementation, bytes calldata data)\n        external\n        payable\n        onlyProxyAdmin\n        onlyWhitelistedImplementation(newImplementation)\n    {\n        _setImplementation(newImplementation, data);\n    }\n\n    // /////////////////////// MODIFIERS ////////////////////////////////////////////////////////////////////////\n\n    modifier onlyProxyAdmin() {\n        require(msg.sender == _proxyAdmin(), \"NOT_AUTHORIZED\");\n        _;\n    }\n\n    // ///////////////////////// INTERNAL //////////////////////////////////////////////////////////////////////\n\n    function _proxyAdmin() internal view returns (address adminAddress) {\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            adminAddress := sload(\n                0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n            )\n        }\n    }\n\n    function _setProxyAdmin(address newAdmin) internal {\n        address previousAdmin = _proxyAdmin();\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            sstore(\n                0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103,\n                newAdmin\n            )\n        }\n        emit ProxyAdminTransferred(previousAdmin, newAdmin);\n    }\n}\n"
    },
    "contracts/interfaces/IOpsProxyFactory.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\ninterface IOpsProxyFactory {\n    /**\n     * @notice Emitted when an OpsProxy is deployed.\n     *\n     * @param deployer Address which initiated the deployment\n     * @param owner The address which the proxy is for.\n     * @param proxy Address of deployed proxy.\n     */\n    event DeployProxy(\n        address indexed deployer,\n        address indexed owner,\n        address indexed proxy\n    );\n\n    /**\n     * @notice Emitted when OpsProxy implementation to be deployed is changed.\n     *\n     * @param oldImplementation Previous OpsProxy implementation.\n     * @param newImplementation Current OpsProxy implementation.\n     */\n    event SetImplementation(\n        address indexed oldImplementation,\n        address indexed newImplementation\n    );\n\n    /**\n     * @notice Emitted when OpsProxy implementation is added or removed from whitelist.\n     *\n     * @param implementation OpsProxy implementation.\n     * @param whitelisted Added or removed from whitelist.\n     */\n    event UpdateWhitelistedImplementation(\n        address indexed implementation,\n        bool indexed whitelisted\n    );\n\n    /**\n     * @notice Deploys OpsProxy for the msg.sender.\n     *\n     * @return proxy Address of deployed proxy.\n     */\n    function deploy() external returns (address payable proxy);\n\n    /**\n     * @notice Deploys OpsProxy for another address.\n     *\n     * @param owner Address to deploy the proxy for.\n     *\n     * @return proxy Address of deployed proxy.\n     */\n    function deployFor(address owner) external returns (address payable proxy);\n\n    /**\n     * @notice Sets the OpsProxy implementation that will be deployed by OpsProxyFactory.\n     *\n     * @param newImplementation New implementation to be set.\n     */\n    function setImplementation(address newImplementation) external;\n\n    /**\n     * @notice Add or remove OpsProxy implementation from the whitelist.\n     *\n     * @param implementation OpsProxy implementation.\n     * @param whitelist Added or removed from whitelist.\n     */\n    function updateWhitelistedImplementations(\n        address implementation,\n        bool whitelist\n    ) external;\n\n    /**\n     * @notice Determines the OpsProxy address when it is not deployed.\n     *\n     * @param account Address to determine the proxy address for.\n     */\n    function determineProxyAddress(address account)\n        external\n        view\n        returns (address);\n\n    /**\n     * @return address Proxy address owned by account.\n     * @return bool Whether if proxy is deployed\n     */\n    function getProxyOf(address account) external view returns (address, bool);\n\n    /**\n     * @return address Owner of deployed proxy.\n     */\n    function ownerOf(address proxy) external view returns (address);\n\n    /**\n     * @return bool Whether if implementation is whitelisted.\n     */\n    function whitelistedImplementations(address implementation)\n        external\n        view\n        returns (bool);\n}\n"
    },
    "contracts/vendor/proxy/EIP173/Proxy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\n// EIP-1967\nabstract contract Proxy {\n    // /////////////////////// EVENTS ///////////////////////////////////////////////////////////////////////////\n\n    event ProxyImplementationUpdated(\n        address indexed previousImplementation,\n        address indexed newImplementation\n    );\n\n    // ///////////////////// EXTERNAL ///////////////////////////////////////////////////////////////////////////\n\n    // prettier-ignore\n    receive() external payable virtual {\n        revert(\"ETHER_REJECTED\"); // explicit reject by default\n    }\n\n    fallback() external payable {\n        _fallback();\n    }\n\n    // ///////////////////////// INTERNAL //////////////////////////////////////////////////////////////////////\n\n    function _fallback() internal {\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            let implementationAddress := sload(\n                0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n            )\n            calldatacopy(0x0, 0x0, calldatasize())\n            let success := delegatecall(\n                gas(),\n                implementationAddress,\n                0x0,\n                calldatasize(),\n                0,\n                0\n            )\n            let retSz := returndatasize()\n            returndatacopy(0, 0, retSz)\n            switch success\n            case 0 {\n                revert(0, retSz)\n            }\n            default {\n                return(0, retSz)\n            }\n        }\n    }\n\n    function _setImplementation(address newImplementation, bytes memory data)\n        internal\n    {\n        address previousImplementation;\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            previousImplementation := sload(\n                0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n            )\n        }\n\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            sstore(\n                0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc,\n                newImplementation\n            )\n        }\n\n        emit ProxyImplementationUpdated(\n            previousImplementation,\n            newImplementation\n        );\n\n        if (data.length > 0) {\n            (bool success, ) = newImplementation.delegatecall(data);\n            if (!success) {\n                assembly {\n                    // This assembly ensure the revert contains the exact string data\n                    let returnDataSize := returndatasize()\n                    returndatacopy(0, 0, returnDataSize)\n                    revert(0, returnDataSize)\n                }\n            }\n        }\n    }\n}\n"
    },
    "contracts/taskModules/ProxyModule.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {TaskModuleBase} from \"./TaskModuleBase.sol\";\nimport {IOpsProxy} from \"../interfaces/IOpsProxy.sol\";\nimport {IOpsProxyFactory} from \"../interfaces/IOpsProxyFactory.sol\";\n\ncontract ProxyModule is TaskModuleBase {\n    IOpsProxyFactory public immutable opsProxyFactory;\n\n    constructor(IOpsProxyFactory _opsProxyFactory) {\n        opsProxyFactory = _opsProxyFactory;\n    }\n\n    /**\n     * @inheritdoc TaskModuleBase\n     */\n    function onCreateTask(\n        bytes32,\n        address _taskCreator,\n        address,\n        bytes calldata,\n        bytes calldata\n    ) external override {\n        _deployIfNoProxy(_taskCreator);\n    }\n\n    /**\n     * @inheritdoc TaskModuleBase\n     * @dev _taskCreator cannot create task to other user's proxy\n     */\n    function preCreateTask(address _taskCreator, address _execAddress)\n        external\n        view\n        override\n        returns (address, address)\n    {\n        address ownerOfExecAddress = opsProxyFactory.ownerOf(_execAddress);\n\n        if (ownerOfExecAddress != address(0)) {\n            // creating task to proxy\n            require(\n                _taskCreator == ownerOfExecAddress ||\n                    _taskCreator == _execAddress,\n                \"ProxyModule: Only owner of proxy\"\n            );\n\n            return (ownerOfExecAddress, _execAddress);\n        } else {\n            address ownerOfTaskCreator = opsProxyFactory.ownerOf(_taskCreator);\n\n            if (ownerOfTaskCreator != address(0)) {\n                // creating task to non proxy, with proxy\n                // give task ownership to proxy owner\n                return (ownerOfTaskCreator, _execAddress);\n            }\n\n            // creating task to non proxy, without proxy\n            return (_taskCreator, _execAddress);\n        }\n    }\n\n    function preCancelTask(bytes32, address _taskCreator)\n        external\n        view\n        override\n        returns (address)\n    {\n        address ownerOfTaskCreator = opsProxyFactory.ownerOf(_taskCreator);\n\n        if (ownerOfTaskCreator != address(0)) {\n            return ownerOfTaskCreator;\n        }\n\n        return _taskCreator;\n    }\n\n    /**\n     * @inheritdoc TaskModuleBase\n     * @dev _execData is encoded with proxy's `executeCall` function\n     * unless _execAddress is OpsProxy which assumes that _execData is encoded\n     * with `executeCall` or `batchExecuteCall`.\n     */\n    function preExecCall(\n        bytes32,\n        address _taskCreator,\n        address _execAddress,\n        bytes calldata _execData\n    ) external view override returns (address, bytes memory execData) {\n        (address proxy, ) = opsProxyFactory.getProxyOf(_taskCreator);\n\n        execData = _execAddress == proxy\n            ? _execData\n            : _encodeWithOpsProxy(_execAddress, _execData);\n\n        _execAddress = proxy;\n\n        return (_execAddress, execData);\n    }\n\n    function _deployIfNoProxy(address _taskCreator) private {\n        bool isTaskCreatorProxy = opsProxyFactory.ownerOf(_taskCreator) !=\n            address(0);\n\n        if (!isTaskCreatorProxy) {\n            (, bool deployed) = opsProxyFactory.getProxyOf(_taskCreator);\n            if (!deployed) opsProxyFactory.deployFor(_taskCreator);\n        }\n    }\n\n    function _encodeWithOpsProxy(address _execAddress, bytes calldata _execData)\n        private\n        pure\n        returns (bytes memory)\n    {\n        return\n            abi.encodeWithSelector(\n                IOpsProxy.executeCall.selector,\n                _execAddress,\n                _execData,\n                0\n            );\n    }\n}\n"
    },
    "contracts/interfaces/IOpsProxy.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.12;\n\ninterface IOpsProxy {\n    /**\n     * @notice Emitted when proxy calls a contract successfully in `executeCall`\n     *\n     * @param target Address of contract that is called\n     * @param data Data used in the call.\n     * @param value Native token value used in the call.\n     * @param returnData Data returned by the call.\n     */\n    event ExecuteCall(\n        address indexed target,\n        bytes data,\n        uint256 value,\n        bytes returnData\n    );\n\n    /**\n     * @notice Multicall to different contracts with different datas.\n     *\n     * @param targets Addresses of contracts to be called.\n     * @param datas Datas for each contract call.\n     * @param values Native token value for each contract call.\n     */\n    function batchExecuteCall(\n        address[] calldata targets,\n        bytes[] calldata datas,\n        uint256[] calldata values\n    ) external payable;\n\n    /**\n     * @notice Call to a single contract.\n     *\n     * @param target Address of contracts to be called.\n     * @param data Data for contract call.\n     * @param value Native token value for contract call.\n     */\n    function executeCall(\n        address target,\n        bytes calldata data,\n        uint256 value\n    ) external payable;\n\n    /**\n     * @return address Ops smart contract address\n     */\n    function ops() external view returns (address);\n\n    /**\n     * @return address Owner of the proxy\n     */\n    function owner() external view returns (address);\n\n    /**\n     * @return uint256 version of OpsProxy.\n     */\n    function version() external view returns (uint256);\n}\n"
    },
    "contracts/opsProxy/OpsProxy.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.12;\n\nimport {Proxied} from \"../vendor/proxy/EIP173/Proxied.sol\";\nimport {_call} from \"../functions/FExec.sol\";\nimport {IOpsProxy} from \"../interfaces/IOpsProxy.sol\";\n\ncontract OpsProxy is Proxied, IOpsProxy {\n    // solhint-disable const-name-snakecase\n    uint256 public constant override version = 1;\n    address public immutable override ops;\n\n    modifier onlyAuth() {\n        address proxyOwner = owner();\n        if (msg.sender != proxyOwner) {\n            require(msg.sender == ops, \"OpsProxy: Not authorised\");\n            require(\n                _getTaskCreator() == proxyOwner,\n                \"OpsProxy: Only tasks created by owner\"\n            );\n        } // else msg.sender == proxyOwner\n        _;\n    }\n\n    // solhint-disable no-empty-blocks\n    constructor(address _ops) {\n        ops = _ops;\n    }\n\n    receive() external payable {}\n\n    ///@inheritdoc IOpsProxy\n    function batchExecuteCall(\n        address[] calldata _targets,\n        bytes[] calldata _datas,\n        uint256[] calldata _values\n    ) external payable override onlyAuth {\n        uint256 length = _targets.length;\n        require(\n            length == _datas.length && length == _values.length,\n            \"OpsProxy: Length mismatch\"\n        );\n\n        for (uint256 i; i < length; i++)\n            _executeCall(_targets[i], _datas[i], _values[i]);\n    }\n\n    ///@inheritdoc IOpsProxy\n    function executeCall(\n        address _target,\n        bytes calldata _data,\n        uint256 _value\n    ) external payable override onlyAuth {\n        _executeCall(_target, _data, _value);\n    }\n\n    function owner() public view returns (address) {\n        return _proxyAdmin();\n    }\n\n    function _executeCall(\n        address _target,\n        bytes calldata _data,\n        uint256 _value\n    ) private {\n        (, bytes memory returnData) = _call(\n            _target,\n            _data,\n            _value,\n            true,\n            \"OpsProxy.executeCall: \"\n        );\n\n        emit ExecuteCall(_target, _data, _value, returnData);\n    }\n\n    function _getTaskCreator() private pure returns (address taskCreator) {\n        assembly {\n            taskCreator := shr(96, calldataload(sub(calldatasize(), 20)))\n        }\n    }\n}\n"
    },
    "contracts/vendor/proxy/EIP173/EIP173Proxy.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./Proxy.sol\";\n\ninterface ERC165 {\n    function supportsInterface(bytes4 id) external view returns (bool);\n}\n\n///@notice Proxy implementing EIP173 for ownership management\ncontract EIP173Proxy is Proxy {\n    // ////////////////////////// EVENTS ///////////////////////////////////////////////////////////////////////\n\n    event ProxyAdminTransferred(\n        address indexed previousAdmin,\n        address indexed newAdmin\n    );\n\n    // /////////////////////// CONSTRUCTOR //////////////////////////////////////////////////////////////////////\n\n    constructor(\n        address implementationAddress,\n        address adminAddress,\n        bytes memory data\n    ) payable {\n        _setImplementation(implementationAddress, data);\n        _setProxyAdmin(adminAddress);\n    }\n\n    // ///////////////////// EXTERNAL ///////////////////////////////////////////////////////////////////////////\n\n    function proxyAdmin() external view returns (address) {\n        return _proxyAdmin();\n    }\n\n    function supportsInterface(bytes4 id) external view returns (bool) {\n        if (id == 0x01ffc9a7 || id == 0x7f5828d0) {\n            return true;\n        }\n        if (id == 0xFFFFFFFF) {\n            return false;\n        }\n\n        ERC165 implementation;\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            implementation := sload(\n                0x360894a13ba1a3210667c828492db98dca3e2076cc3735a920a3ca505d382bbc\n            )\n        }\n\n        // Technically this is not standard compliant as ERC-165 require 30,000 gas which that call cannot ensure\n        // because it is itself inside `supportsInterface` that might only get 30,000 gas.\n        // In practise this is unlikely to be an issue.\n        try implementation.supportsInterface(id) returns (bool support) {\n            return support;\n        } catch {\n            return false;\n        }\n    }\n\n    function transferProxyAdmin(address newAdmin) external onlyProxyAdmin {\n        _setProxyAdmin(newAdmin);\n    }\n\n    function upgradeTo(address newImplementation) external onlyProxyAdmin {\n        _setImplementation(newImplementation, \"\");\n    }\n\n    function upgradeToAndCall(address newImplementation, bytes calldata data)\n        external\n        payable\n        onlyProxyAdmin\n    {\n        _setImplementation(newImplementation, data);\n    }\n\n    // /////////////////////// MODIFIERS ////////////////////////////////////////////////////////////////////////\n\n    modifier onlyProxyAdmin() {\n        require(msg.sender == _proxyAdmin(), \"NOT_AUTHORIZED\");\n        _;\n    }\n\n    // ///////////////////////// INTERNAL //////////////////////////////////////////////////////////////////////\n\n    function _proxyAdmin() internal view returns (address adminAddress) {\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            adminAddress := sload(\n                0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103\n            )\n        }\n    }\n\n    function _setProxyAdmin(address newAdmin) internal {\n        address previousAdmin = _proxyAdmin();\n        // solhint-disable-next-line security/no-inline-assembly\n        assembly {\n            sstore(\n                0xb53127684a568b3173ae13b9f8a6016e243e63b6e8ee1178d6a717850b5d6103,\n                newAdmin\n            )\n        }\n        emit ProxyAdminTransferred(previousAdmin, newAdmin);\n    }\n}\n"
    },
    "contracts/vendor/proxy/EIP173/EIP173ProxyWithCustomReceive.sol": {
      "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.12;\n\nimport \"./EIP173Proxy.sol\";\n\n///@notice Proxy implementing EIP173 for ownership management that accept ETH via receive\ncontract EIP173ProxyWithCustomReceive is EIP173Proxy {\n    constructor(\n        address implementationAddress,\n        address ownerAddress,\n        bytes memory data\n    ) payable EIP173Proxy(implementationAddress, ownerAddress, data) {}\n\n    receive() external payable override {\n        _fallback();\n    }\n}\n"
    },
    "contracts/integrations/examples/userCreator/withoutTreasury/CounterResolverWT.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface ICounter {\n    function increaseCount(uint256 amount) external;\n\n    function lastExecuted() external view returns (uint256);\n}\n\n// solhint-disable not-rely-on-time\ncontract CounterResolverWT {\n    ICounter public immutable counter;\n\n    constructor(ICounter _counter) {\n        counter = _counter;\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        uint256 lastExecuted = counter.lastExecuted();\n\n        canExec = (block.timestamp - lastExecuted) > 180;\n\n        execPayload = abi.encodeCall(ICounter.increaseCount, (1));\n    }\n}\n"
    },
    "contracts/integrations/examples/userCreator/withTreasury/CounterResolver.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ninterface ICounter {\n    function increaseCount(uint256 amount) external;\n\n    function lastExecuted() external view returns (uint256);\n}\n\n// solhint-disable not-rely-on-time\ncontract CounterResolver {\n    ICounter public immutable counter;\n\n    constructor(ICounter _counter) {\n        counter = _counter;\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        uint256 lastExecuted = counter.lastExecuted();\n\n        canExec = (block.timestamp - lastExecuted) > 180;\n\n        execPayload = abi.encodeCall(ICounter.increaseCount, (1));\n    }\n}\n"
    },
    "contracts/interfaces/IResolver.sol": {
      "content": "// SPDX-License-Identifier: MIT\npragma solidity ^0.8.0;\n\n/**\n * @notice Standard interface that should be used when creating a resolver.\n *\n * NOTE `checker` can be non view as well as it will be\n * called with static call off chain\n */\ninterface IResolver {\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload);\n}\n"
    },
    "contracts/tests/CounterTest.sol": {
      "content": "// SPDX-License-Identifier: UNLICENSED\npragma solidity ^0.8.0;\n\ncontract CounterTest {\n    address public ops;\n    uint256 public count;\n    uint256 public lastExecuted;\n\n    constructor(address payable _ops) {\n        ops = _ops;\n    }\n\n    // solhint-disable not-rely-on-time\n    function increaseCount(uint256 amount) external {\n        require(\n            ((block.timestamp - lastExecuted) > 180),\n            \"Counter: increaseCount: Time not elapsed\"\n        );\n\n        count += amount;\n        lastExecuted = block.timestamp;\n    }\n\n    function checker()\n        external\n        view\n        returns (bool canExec, bytes memory execPayload)\n    {\n        canExec = (block.timestamp - lastExecuted) > 180;\n\n        execPayload = abi.encodeCall(this.increaseCount, (1));\n    }\n}\n"
    }
  },
  "settings": {
    "optimizer": {
      "enabled": false,
      "runs": 200
    },
    "outputSelection": {
      "*": {
        "*": [
          "abi",
          "evm.bytecode",
          "evm.deployedBytecode",
          "evm.methodIdentifiers",
          "metadata",
          "devdoc",
          "userdoc",
          "storageLayout",
          "evm.gasEstimates"
        ],
        "": ["ast"]
      }
    },
    "metadata": {
      "useLiteralContent": true
    }
  }
}
