creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/ConstantProductFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\nimport {SafeERC20} from \"lib/openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport {ICOWAMMPoolFactory} from \"./interfaces/ICOWAMMPoolFactory.sol\";\nimport {ConstantProduct, IERC20, OZIERC20, ISettlement, GPv2Order, IPriceOracle} from \"./ConstantProduct.sol\";\n\n/**\n * @title CoW AMM Factory\n * @author CoW Protocol Developers\n * @dev Factory contract for the CoW AMM, an automated market maker based on the\n * concept of function-maximising AMMs.\n * The factory deploys new AMM and is responsible for managing deposits,\n * enabling/disabling trading and updating trade parameters.\n */\ncontract ConstantProductFactory is ICOWAMMPoolFactory {\n    using SafeERC20 for OZIERC20;\n\n    /**\n     * @notice The settlement contract for CoW Protocol on this network.\n     */\n    ISettlement public immutable settler;\n\n    /**\n     * @notice For each AMM created by this contract, this mapping stores its\n     * owner.\n     */\n    mapping(ConstantProduct => address) public owner;\n\n    /**\n     * @notice A CoW AMM has been created. The emitted AMM parameters are\n     * immutable for the new AMM.\n     * @param amm The address of the AMM that can now trade on CoW Protocol.\n     * @param owner The owner of the AMM.\n     * @param token0 The first token traded by the AMM.\n     * @param token1 The second token traded by the AMM.\n     */\n    event Deployed(ConstantProduct indexed amm, address indexed owner, IERC20 token0, IERC20 token1);\n    /**\n     * @notice A CoW AMM started trading.\n     * @param amm The address of the AMM that starts trading on CoW Protocol.\n     */\n    event TradingEnabled(ConstantProduct indexed amm);\n    /**\n     * @notice A CoW AMM stopped trading; no CoW Protocol orders can be settled\n     * until trading is enabled again.\n     * @param amm The address of the AMM that stops trading on CoW Protocol.\n     */\n    event TradingDisabled(ConstantProduct indexed amm);\n\n    /**\n     * @notice This function is permissioned and can only be called by the\n     * owner of the AMM that is involved in the transaction.\n     * @param owner The owner of the AMM.\n     */\n    error OnlyOwnerCanCall(address owner);\n\n    modifier onlyOwner(ConstantProduct amm) {\n        if (owner[amm] != msg.sender) {\n            revert OnlyOwnerCanCall(owner[amm]);\n        }\n        _;\n    }\n\n    /**\n     * @param _settler The address of the GPv2Settlement contract.\n     */\n    constructor(ISettlement _settler) {\n        settler = _settler;\n    }\n\n    /**\n     * @notice Creates a new CoW AMM with the specified imput parameters.\n     * @param token0 The address of the first token in the pair.\n     * @param amount0 The initial amount of the first token in the pair.\n     * @param token1 The address of the second token in the pair.\n     * @param amount1 The initial amount of the second token in the pair.\n     * @return amm The address of the newly deployed AMM.\n     */\n    function create(IERC20 token0, uint256 amount0, IERC20 token1, uint256 amount1)\n        external\n        returns (ConstantProduct amm)\n    {\n        address ammOwner = msg.sender;\n        amm = new ConstantProduct{salt: salt(ammOwner)}(settler, token0, token1);\n        emit Deployed(amm, ammOwner, token0, token1);\n        emit COWAMMPoolCreated(address(amm));\n        owner[amm] = ammOwner;\n\n        deposit(amm, amount0, amount1);\n\n        _enableTrading(amm);\n    }\n\n    /**\n     * @notice Disable trading for an AMM managed by this contract.\n     * @param amm The AMM for which to disable trading.\n     */\n    function disableTrading(ConstantProduct amm) external onlyOwner(amm) {\n        _disableTrading(amm);\n    }\n\n    /**\n     * @notice Take funds from the AMM and sends them to the owner.\n     * @param amm the AMM whose funds to withdraw\n     * @param amount0 amount of AMM's token0 to withdraw\n     * @param amount1 amount of AMM's token1 to withdraw\n     */\n    function withdraw(ConstantProduct amm, uint256 amount0, uint256 amount1) external onlyOwner(amm) {\n        OZIERC20(address(amm.token0())).safeTransferFrom(address(amm), msg.sender, amount0);\n        OZIERC20(address(amm.token1())).safeTransferFrom(address(amm), msg.sender, amount1);\n    }\n\n    /**\n     * @notice Computes the determinisitic address of a CoW AMM deployment.\n     * @param ammOwner The (expected) owner of the AMM.\n     * @param token0 The address of the first token traded by the AMM.\n     * @param token1 The address of the second token traded by the AMM.\n     * @return The deterministic address at which this contract deploys a CoW\n     * AMM for the specified input parameters.\n     */\n    function ammDeterministicAddress(address ammOwner, IERC20 token0, IERC20 token1) external view returns (address) {\n        // https://eips.ethereum.org/EIPS/eip-1014#specification\n        bytes32 create2Hash = keccak256(\n            abi.encodePacked(\n                bytes1(0xff),\n                address(this),\n                salt(ammOwner),\n                keccak256(\n                    bytes.concat(\n                        type(ConstantProduct).creationCode,\n                        // Input parameters are appended at the end of the\n                        // creation bytecode.\n                        abi.encode(settler, token0, token1)\n                    )\n                )\n            )\n        );\n\n        // Take the last 20 bytes of the hash as the address.\n        return address(uint160(uint256(create2Hash)));\n    }\n\n    /**\n     * @notice Deposit sender's funds into the the AMM contract, assuming that\n     * the sender has approved this contract to spend both tokens.\n     * @param amm the AMM where to send the funds\n     * @param amount0 amount of AMM's token0 to deposit\n     * @param amount1 amount of AMM's token1 to deposit\n     */\n    function deposit(ConstantProduct amm, uint256 amount0, uint256 amount1) public {\n        OZIERC20(address(amm.token0())).safeTransferFrom(msg.sender, address(amm), amount0);\n        OZIERC20(address(amm.token1())).safeTransferFrom(msg.sender, address(amm), amount1);\n    }\n\n    /**\n     * @notice Enable trading for an existing AMM that is managed by this\n     * contract.\n     * @param amm The AMM for which to enable trading.\n     */\n    function _enableTrading(ConstantProduct amm) internal {\n        amm.enableTrading();\n        emit TradingEnabled(amm);\n    }\n\n    /**\n     * @notice Disable trading for an AMM managed by this contract.\n     * @param amm The AMM for which to disable trading.\n     */\n    function _disableTrading(ConstantProduct amm) internal {\n        amm.disableTrading();\n        emit TradingDisabled(amm);\n    }\n\n    /**\n     * @notice Salt parameter used for deterministic AMM deployments.\n     * @param ammOwner The (expected) owner of the AMM.\n     * @return The salt to use for deploying the AMM with CREATE2.\n     */\n    function salt(address ammOwner) internal pure returns (bytes32) {\n        return bytes32(uint256(uint160(ammOwner)));\n    }\n}\n"
      },
      "lib/openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.3) (token/ERC20/utils/SafeERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../IERC20.sol\";\nimport \"../extensions/IERC20Permit.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    /**\n     * @dev Transfer `value` amount of `token` from the calling contract to `to`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeTransfer(IERC20 token, address to, uint256 value) internal {\n        _callOptionalReturn(token, abi.encodeWithSelector(token.transfer.selector, to, value));\n    }\n\n    /**\n     * @dev Transfer `value` amount of `token` from `from` to `to`, spending the approval given by `from` to the\n     * calling contract. If `token` returns no value, non-reverting calls are assumed to be successful.\n     */\n    function safeTransferFrom(IERC20 token, address from, address to, uint256 value) 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(IERC20 token, address spender, uint256 value) 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    /**\n     * @dev Increase the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeIncreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        uint256 oldAllowance = token.allowance(address(this), spender);\n        _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance + value));\n    }\n\n    /**\n     * @dev Decrease the calling contract's allowance toward `spender` by `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful.\n     */\n    function safeDecreaseAllowance(IERC20 token, address spender, uint256 value) internal {\n        unchecked {\n            uint256 oldAllowance = token.allowance(address(this), spender);\n            require(oldAllowance >= value, \"SafeERC20: decreased allowance below zero\");\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, oldAllowance - value));\n        }\n    }\n\n    /**\n     * @dev Set the calling contract's allowance toward `spender` to `value`. If `token` returns no value,\n     * non-reverting calls are assumed to be successful. Meant to be used with tokens that require the approval\n     * to be set to zero before setting it to a non-zero value, such as USDT.\n     */\n    function forceApprove(IERC20 token, address spender, uint256 value) internal {\n        bytes memory approvalCall = abi.encodeWithSelector(token.approve.selector, spender, value);\n\n        if (!_callOptionalReturnBool(token, approvalCall)) {\n            _callOptionalReturn(token, abi.encodeWithSelector(token.approve.selector, spender, 0));\n            _callOptionalReturn(token, approvalCall);\n        }\n    }\n\n    /**\n     * @dev Use a ERC-2612 signature to set the `owner` approval toward `spender` on `token`.\n     * Revert on invalid signature.\n     */\n    function safePermit(\n        IERC20Permit token,\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) internal {\n        uint256 nonceBefore = token.nonces(owner);\n        token.permit(owner, spender, value, deadline, v, r, s);\n        uint256 nonceAfter = token.nonces(owner);\n        require(nonceAfter == nonceBefore + 1, \"SafeERC20: permit did not succeed\");\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        require(returndata.length == 0 || abi.decode(returndata, (bool)), \"SafeERC20: ERC20 operation did not succeed\");\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     * This is a variant of {_callOptionalReturn} that silents catches all reverts and returns a bool instead.\n     */\n    function _callOptionalReturnBool(IERC20 token, bytes memory data) private returns (bool) {\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 cannot use {Address-functionCall} here since this should return false\n        // and not revert is the subcall reverts.\n\n        (bool success, bytes memory returndata) = address(token).call(data);\n        return\n            success && (returndata.length == 0 || abi.decode(returndata, (bool))) && Address.isContract(address(token));\n    }\n}\n"
      },
      "src/interfaces/ICOWAMMPoolFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\n/**\n * @title Helper factory interface for back-end readability of deployed AMMs\n * @author CoW Protocol Developers\n */\ninterface ICOWAMMPoolFactory {\n    /**\n     * AMM protocols capable of operating as a CoW AMM MUST emit an event on pool\n     * creation.\n     * @param amm The address of the newly tradeable CoW AMM Pool\n     */\n    event COWAMMPoolCreated(address amm);\n}\n"
      },
      "src/ConstantProduct.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\nimport {IERC20 as OZIERC20} from \"lib/openzeppelin/contracts/interfaces/IERC20.sol\";\nimport {IERC1271} from \"lib/openzeppelin/contracts/interfaces/IERC1271.sol\";\nimport {SafeERC20} from \"lib/openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\nimport {Math} from \"lib/openzeppelin/contracts/utils/math/Math.sol\";\nimport {ConditionalOrdersUtilsLib as Utils} from \"lib/composable-cow/src/types/ConditionalOrdersUtilsLib.sol\";\nimport {IConditionalOrder, GPv2Order, IERC20} from \"lib/composable-cow/src/BaseConditionalOrder.sol\";\n\nimport {IPriceOracle} from \"./interfaces/IPriceOracle.sol\";\nimport {ISettlement} from \"./interfaces/ISettlement.sol\";\n\n/**\n * @title CoW AMM\n * @author CoW Protocol Developers\n * @dev Automated market maker based on the concept of function-maximising AMMs.\n * It relies on the CoW Protocol infrastructure to guarantee batch execution of\n * its orders.\n * Order creation and execution is based on the Composable CoW base contracts.\n */\ncontract ConstantProduct is IERC1271 {\n    using SafeERC20 for OZIERC20;\n    using GPv2Order for GPv2Order.Data;\n\n    /**\n     * @notice The largest possible duration of any AMM order, starting from the\n     * current block timestamp.\n     */\n    uint32 public constant MAX_ORDER_DURATION = 5 * 60;\n    /**\n     * @notice The value representing the absence of a commitment. It signifies\n     * that the AMM will enforce that the order matches the order obtained from\n     * calling `getTradeableOrder`.\n     */\n    bytes32 public constant EMPTY_COMMITMENT = bytes32(0);\n    /**\n     * @notice The transient storage slot specified in this variable stores the\n     * value of the order commitment, that is, the only order hash that can be\n     * validated by calling `isValidSignature`.\n     * The hash corresponding to the constant `EMPTY_COMMITMENT` has special\n     * semantics, discussed in the related documentation.\n     * @dev This value is:\n     * uint256(keccak256(\"CoWAMM.ConstantProduct.commitment\")) - 1\n     */\n    uint256 public constant COMMITMENT_SLOT = 0x6c3c90245457060f6517787b2c4b8cf500ca889d2304af02043bd5b513e3b593;\n    /**\n     * @dev {\"appCode\":\"Testing CoW AMM: abridged standalone\",\"version\":\"1.1.0\"}\n     */\n    bytes32 public constant APP_DATA = 0x555ea39564bc0bdb86c923141da12754e14676ae1fd8fcf6b26ae04abdfa0298;\n\n    /**\n     * @notice The address of the CoW Protocol settlement contract. It is the\n     * only address that can set commitments.\n     */\n    ISettlement public immutable solutionSettler;\n    /**\n     * @notice The first of the two tokens traded by this AMM.\n     */\n    IERC20 public immutable token0;\n    /**\n     * @notice The second of the two tokens traded by this AMM.\n     */\n    IERC20 public immutable token1;\n    /**\n     * @notice The address that can execute administrative tasks on this AMM,\n     * as for example enabling/disabling trading or withdrawing funds.\n     */\n    address public immutable manager;\n    /**\n     * @notice The domain separator used for hashing CoW Protocol orders.\n     */\n    bytes32 public immutable solutionSettlerDomainSeparator;\n\n    /**\n     * Is trading enabled?\n     */\n    bool public tradingEnabled = false;\n\n    /**\n     * Emitted when the manager disables all trades by the AMM. Existing open\n     * order will not be tradeable. Note that the AMM could resume trading with\n     * different parameters at a later point.\n     */\n    event TradingDisabled();\n    /**\n     * Emitted when the manager enables the AMM to trade on CoW Protocol.\n     */\n    event TradingEnabled();\n\n    /**\n     * @notice This function is permissioned and can only be called by the\n     * contract's manager.\n     */\n    error OnlyManagerCanCall();\n    /**\n     * @notice The `commit` function can only be called inside a CoW Swap\n     * settlement. This error is thrown when the function is called from another\n     * context.\n     */\n    error CommitOutsideOfSettlement();\n    /**\n     * @notice Error thrown when a solver tries to settle an AMM order on CoW\n     * Protocol whose hash doesn't match the one that has been committed to.\n     */\n    error OrderDoesNotMatchCommitmentHash();\n    /**\n     * @notice If an AMM order is settled and the AMM committment is set to\n     * empty, then that order must match the output of `getTradeableOrder`.\n     * This error is thrown when some of the parameters don't match the expected\n     * ones.\n     */\n    error OrderDoesNotMatchDefaultTradeableOrder();\n    /**\n     * @notice On signature verification, the hash of the order supplied as part\n     * of the signature does not match the provided message hash.\n     * This usually means that the verification function is being provided a\n     * signature that belongs to a different order.\n     */\n    error OrderDoesNotMatchMessageHash();\n\n    modifier onlyManager() {\n        if (manager != msg.sender) {\n            revert OnlyManagerCanCall();\n        }\n        _;\n    }\n\n    /**\n     * @param _solutionSettler The CoW Protocol contract used to settle user\n     * orders on the current chain.\n     * @param _token0 The first of the two tokens traded by this AMM.\n     * @param _token1 The second of the two tokens traded by this AMM.\n     */\n    constructor(ISettlement _solutionSettler, IERC20 _token0, IERC20 _token1) {\n        solutionSettler = _solutionSettler;\n        solutionSettlerDomainSeparator = _solutionSettler.domainSeparator();\n\n        approveUnlimited(_token0, msg.sender);\n        approveUnlimited(_token1, msg.sender);\n        manager = msg.sender;\n\n        address vaultRelayer = _solutionSettler.vaultRelayer();\n        approveUnlimited(_token0, vaultRelayer);\n        approveUnlimited(_token1, vaultRelayer);\n\n        token0 = _token0;\n        token1 = _token1;\n    }\n\n    /**\n     * @notice Once this function is called, it will be possible to trade with\n     * this AMM on CoW Protocol.\n     */\n    function enableTrading() external onlyManager {\n        tradingEnabled = true;\n        emit TradingEnabled();\n    }\n\n    /**\n     * @notice Disable any form of trading on CoW Protocol by this AMM.\n     */\n    function disableTrading() external onlyManager {\n        tradingEnabled = false;\n        emit TradingDisabled();\n    }\n\n    /**\n     * @notice Restricts a specific AMM to being able to trade only the order\n     * with the specified hash.\n     * @dev The commitment is used to enforce that exactly one AMM order is\n     * valid when a CoW Protocol batch is settled.\n     * @param orderHash the order hash that will be enforced by the order\n     * verification function.\n     */\n    function commit(bytes32 orderHash) external {\n        if (msg.sender != address(solutionSettler)) {\n            revert CommitOutsideOfSettlement();\n        }\n        assembly (\"memory-safe\") {\n            tstore(COMMITMENT_SLOT, orderHash)\n        }\n    }\n\n    /**\n     * @inheritdoc IERC1271\n     */\n    function isValidSignature(bytes32 _hash, bytes calldata signature) external view returns (bytes4) {\n        GPv2Order.Data memory order = abi.decode(signature, (GPv2Order.Data));\n\n        bytes32 orderHash = order.hash(solutionSettlerDomainSeparator);\n        if (orderHash != _hash) {\n            revert OrderDoesNotMatchMessageHash();\n        }\n\n        if (orderHash != commitment()) {\n            revert OrderDoesNotMatchCommitmentHash();\n        }\n\n        verify(order);\n\n        // A signature is valid according to EIP-1271 if this function returns\n        // its selector as the so-called \"magic value\".\n        return this.isValidSignature.selector;\n    }\n\n    /**\n     * @notice This function checks that the input order is admissible for the\n     * constant-product curve for the given trading parameters.\n     * @param order `GPv2Order.Data` of a discrete order to be verified.\n     */\n    function verify(GPv2Order.Data memory order) public view {\n        IERC20 sellToken = token0;\n        IERC20 buyToken = token1;\n        if (order.sellToken != sellToken) {\n            if (order.sellToken != buyToken) {\n                revert IConditionalOrder.OrderNotValid(\"invalid sell token\");\n            }\n            (sellToken, buyToken) = (buyToken, sellToken);\n        }\n        uint256 sellReserve = sellToken.balanceOf(address(this));\n        uint256 buyReserve = buyToken.balanceOf(address(this));\n\n        if (order.buyToken != buyToken) {\n            revert IConditionalOrder.OrderNotValid(\"invalid buy token\");\n        }\n\n        if (order.receiver != GPv2Order.RECEIVER_SAME_AS_OWNER) {\n            revert IConditionalOrder.OrderNotValid(\"receiver must be zero address\");\n        }\n        // We add a maximum duration to avoid spamming the orderbook and force\n        // an order refresh if the order is old.\n        if (order.validTo > block.timestamp + MAX_ORDER_DURATION) {\n            revert IConditionalOrder.OrderNotValid(\"validity too far in the future\");\n        }\n        if (order.appData != APP_DATA) {\n            revert IConditionalOrder.OrderNotValid(\"invalid appData\");\n        }\n        if (order.feeAmount != 0) {\n            revert IConditionalOrder.OrderNotValid(\"fee amount must be zero\");\n        }\n        if (order.buyTokenBalance != GPv2Order.BALANCE_ERC20) {\n            revert IConditionalOrder.OrderNotValid(\"buyTokenBalance must be erc20\");\n        }\n        if (order.sellTokenBalance != GPv2Order.BALANCE_ERC20) {\n            revert IConditionalOrder.OrderNotValid(\"sellTokenBalance must be erc20\");\n        }\n        // These are the checks needed to satisfy the conditions on in/out\n        // amounts for a constant-product curve AMM.\n        if ((sellReserve - order.sellAmount) * order.buyAmount < buyReserve * order.sellAmount) {\n            revert IConditionalOrder.OrderNotValid(\"received amount too low\");\n        }\n\n        // No checks on:\n        // - kind\n        // - partiallyFillable\n    }\n\n    function commitment() public view returns (bytes32 value) {\n        assembly (\"memory-safe\") {\n            value := tload(COMMITMENT_SLOT)\n        }\n    }\n\n    /**\n     * @notice Approves the spender to transfer an unlimited amount of tokens\n     * and reverts if the approval was unsuccessful.\n     * @param token The ERC-20 token to approve.\n     * @param spender The address that can transfer on behalf of this contract.\n     */\n    function approveUnlimited(IERC20 token, address spender) internal {\n        OZIERC20(address(token)).safeApprove(spender, type(uint256).max);\n    }\n}\n"
      },
      "lib/openzeppelin/contracts/token/ERC20/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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 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    /**\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(address from, address to, uint256 amount) external returns (bool);\n}\n"
      },
      "lib/openzeppelin/contracts/token/ERC20/extensions/IERC20Permit.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.0) (token/ERC20/extensions/IERC20Permit.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC20 Permit extension allowing approvals to be made via signatures, as defined in\n * https://eips.ethereum.org/EIPS/eip-2612[EIP-2612].\n *\n * Adds the {permit} method, which can be used to change an account's ERC20 allowance (see {IERC20-allowance}) by\n * presenting a message signed by the account. By not relying on {IERC20-approve}, the token holder account doesn't\n * need to send a transaction, and thus is not required to hold Ether at all.\n */\ninterface IERC20Permit {\n    /**\n     * @dev Sets `value` as the allowance of `spender` over ``owner``'s tokens,\n     * given ``owner``'s signed approval.\n     *\n     * IMPORTANT: The same issues {IERC20-approve} has related to transaction\n     * ordering also apply here.\n     *\n     * Emits an {Approval} event.\n     *\n     * Requirements:\n     *\n     * - `spender` cannot be the zero address.\n     * - `deadline` must be a timestamp in the future.\n     * - `v`, `r` and `s` must be a valid `secp256k1` signature from `owner`\n     * over the EIP712-formatted function arguments.\n     * - the signature must use ``owner``'s current nonce (see {nonces}).\n     *\n     * For more information on the signature format, see the\n     * https://eips.ethereum.org/EIPS/eip-2612#specification[relevant EIP\n     * section].\n     */\n    function permit(\n        address owner,\n        address spender,\n        uint256 value,\n        uint256 deadline,\n        uint8 v,\n        bytes32 r,\n        bytes32 s\n    ) external;\n\n    /**\n     * @dev Returns the current nonce for `owner`. This value must be\n     * included whenever a signature is generated for {permit}.\n     *\n     * Every successful call to {permit} increases ``owner``'s nonce by one. This\n     * prevents a signature from being used multiple times.\n     */\n    function nonces(address owner) external view returns (uint256);\n\n    /**\n     * @dev Returns the domain separator used in the encoding of the signature for {permit}, as defined by {EIP712}.\n     */\n    // solhint-disable-next-line func-name-mixedcase\n    function DOMAIN_SEPARATOR() external view returns (bytes32);\n}\n"
      },
      "lib/openzeppelin/contracts/utils/Address.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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     * Furthermore, `isContract` will also return true if the target contract within\n     * the same transaction is already scheduled for destruction by `SELFDESTRUCT`,\n     * which only has an effect at the end of a transaction.\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://consensys.net/diligence/blog/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.8.0/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 functionCallWithValue(target, data, 0, \"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(address target, bytes memory data, uint256 value) 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        (bool success, bytes memory returndata) = target.call{value: value}(data);\n        return verifyCallResultFromTarget(target, 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        (bool success, bytes memory returndata) = target.staticcall(data);\n        return verifyCallResultFromTarget(target, 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        (bool success, bytes memory returndata) = target.delegatecall(data);\n        return verifyCallResultFromTarget(target, success, returndata, errorMessage);\n    }\n\n    /**\n     * @dev Tool to verify that a low level call to smart-contract was successful, and revert (either by bubbling\n     * the revert reason or using the provided one) in case of unsuccessful call or if target was not a contract.\n     *\n     * _Available since v4.8._\n     */\n    function verifyCallResultFromTarget(\n        address target,\n        bool success,\n        bytes memory returndata,\n        string memory errorMessage\n    ) internal view returns (bytes memory) {\n        if (success) {\n            if (returndata.length == 0) {\n                // only check isContract if the call was successful and the return data is empty\n                // otherwise we already know that it was a contract\n                require(isContract(target), \"Address: call to non-contract\");\n            }\n            return returndata;\n        } else {\n            _revert(returndata, errorMessage);\n        }\n    }\n\n    /**\n     * @dev Tool to verify that a low level call was successful, and revert if it wasn't, either by bubbling the\n     * revert reason or 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            _revert(returndata, errorMessage);\n        }\n    }\n\n    function _revert(bytes memory returndata, string memory errorMessage) private pure {\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            /// @solidity memory-safe-assembly\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"
      },
      "lib/openzeppelin/contracts/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC20.sol)\n\npragma solidity ^0.8.0;\n\nimport \"../token/ERC20/IERC20.sol\";\n"
      },
      "lib/openzeppelin/contracts/interfaces/IERC1271.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts v4.4.1 (interfaces/IERC1271.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev Interface of the ERC1271 standard signature validation method for\n * contracts as defined in https://eips.ethereum.org/EIPS/eip-1271[ERC-1271].\n *\n * _Available since v4.1._\n */\ninterface IERC1271 {\n    /**\n     * @dev Should return whether the signature provided is valid for the provided data\n     * @param hash      Hash of the data to be signed\n     * @param signature Signature byte array associated with _data\n     */\n    function isValidSignature(bytes32 hash, bytes memory signature) external view returns (bytes4 magicValue);\n}\n"
      },
      "lib/openzeppelin/contracts/utils/math/Math.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.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    enum Rounding {\n        Down, // Toward negative infinity\n        Up, // Toward infinity\n        Zero // Toward zero\n    }\n\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 == 0 ? 0 : (a - 1) / b + 1;\n    }\n\n    /**\n     * @notice Calculates floor(x * y / denominator) with full precision. Throws if result overflows a uint256 or denominator == 0\n     * @dev Original credit to Remco Bloemen under MIT license (https://xn--2-umb.com/21/muldiv)\n     * with further edits by Uniswap Labs also under MIT license.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator) internal pure returns (uint256 result) {\n        unchecked {\n            // 512-bit multiply [prod1 prod0] = x * y. Compute the product mod 2^256 and mod 2^256 - 1, then use\n            // use the Chinese Remainder Theorem to reconstruct the 512 bit result. The result is stored in two 256\n            // variables such that product = prod1 * 2^256 + prod0.\n            uint256 prod0; // Least significant 256 bits of the product\n            uint256 prod1; // Most significant 256 bits of the product\n            assembly {\n                let mm := mulmod(x, y, not(0))\n                prod0 := mul(x, y)\n                prod1 := sub(sub(mm, prod0), lt(mm, prod0))\n            }\n\n            // Handle non-overflow cases, 256 by 256 division.\n            if (prod1 == 0) {\n                // Solidity will revert if denominator == 0, unlike the div opcode on its own.\n                // The surrounding unchecked block does not change this fact.\n                // See https://docs.soliditylang.org/en/latest/control-structures.html#checked-or-unchecked-arithmetic.\n                return prod0 / denominator;\n            }\n\n            // Make sure the result is less than 2^256. Also prevents denominator == 0.\n            require(denominator > prod1, \"Math: mulDiv overflow\");\n\n            ///////////////////////////////////////////////\n            // 512 by 256 division.\n            ///////////////////////////////////////////////\n\n            // Make division exact by subtracting the remainder from [prod1 prod0].\n            uint256 remainder;\n            assembly {\n                // Compute remainder using mulmod.\n                remainder := mulmod(x, y, denominator)\n\n                // Subtract 256 bit number from 512 bit number.\n                prod1 := sub(prod1, gt(remainder, prod0))\n                prod0 := sub(prod0, remainder)\n            }\n\n            // Factor powers of two out of denominator and compute largest power of two divisor of denominator. Always >= 1.\n            // See https://cs.stackexchange.com/q/138556/92363.\n\n            // Does not overflow because the denominator cannot be zero at this stage in the function.\n            uint256 twos = denominator & (~denominator + 1);\n            assembly {\n                // Divide denominator by twos.\n                denominator := div(denominator, twos)\n\n                // Divide [prod1 prod0] by twos.\n                prod0 := div(prod0, twos)\n\n                // Flip twos such that it is 2^256 / twos. If twos is zero, then it becomes one.\n                twos := add(div(sub(0, twos), twos), 1)\n            }\n\n            // Shift in bits from prod1 into prod0.\n            prod0 |= prod1 * twos;\n\n            // Invert denominator mod 2^256. Now that denominator is an odd number, it has an inverse modulo 2^256 such\n            // that denominator * inv = 1 mod 2^256. Compute the inverse by starting with a seed that is correct for\n            // four bits. That is, denominator * inv = 1 mod 2^4.\n            uint256 inverse = (3 * denominator) ^ 2;\n\n            // Use the Newton-Raphson iteration to improve the precision. Thanks to Hensel's lifting lemma, this also works\n            // in modular arithmetic, doubling the correct bits in each step.\n            inverse *= 2 - denominator * inverse; // inverse mod 2^8\n            inverse *= 2 - denominator * inverse; // inverse mod 2^16\n            inverse *= 2 - denominator * inverse; // inverse mod 2^32\n            inverse *= 2 - denominator * inverse; // inverse mod 2^64\n            inverse *= 2 - denominator * inverse; // inverse mod 2^128\n            inverse *= 2 - denominator * inverse; // inverse mod 2^256\n\n            // Because the division is now exact we can divide by multiplying with the modular inverse of denominator.\n            // This will give us the correct result modulo 2^256. Since the preconditions guarantee that the outcome is\n            // less than 2^256, this is the final result. We don't need to compute the high bits of the result and prod1\n            // is no longer required.\n            result = prod0 * inverse;\n            return result;\n        }\n    }\n\n    /**\n     * @notice Calculates x * y / denominator with full precision, following the selected rounding direction.\n     */\n    function mulDiv(uint256 x, uint256 y, uint256 denominator, Rounding rounding) internal pure returns (uint256) {\n        uint256 result = mulDiv(x, y, denominator);\n        if (rounding == Rounding.Up && mulmod(x, y, denominator) > 0) {\n            result += 1;\n        }\n        return result;\n    }\n\n    /**\n     * @dev Returns the square root of a number. If the number is not a perfect square, the value is rounded down.\n     *\n     * Inspired by Henry S. Warren, Jr.'s \"Hacker's Delight\" (Chapter 11).\n     */\n    function sqrt(uint256 a) internal pure returns (uint256) {\n        if (a == 0) {\n            return 0;\n        }\n\n        // For our first guess, we get the biggest power of 2 which is smaller than the square root of the target.\n        //\n        // We know that the \"msb\" (most significant bit) of our target number `a` is a power of 2 such that we have\n        // `msb(a) <= a < 2*msb(a)`. This value can be written `msb(a)=2**k` with `k=log2(a)`.\n        //\n        // This can be rewritten `2**log2(a) <= a < 2**(log2(a) + 1)`\n        // → `sqrt(2**k) <= sqrt(a) < sqrt(2**(k+1))`\n        // → `2**(k/2) <= sqrt(a) < 2**((k+1)/2) <= 2**(k/2 + 1)`\n        //\n        // Consequently, `2**(log2(a) / 2)` is a good first approximation of `sqrt(a)` with at least 1 correct bit.\n        uint256 result = 1 << (log2(a) >> 1);\n\n        // At this point `result` is an estimation with one bit of precision. We know the true value is a uint128,\n        // since it is the square root of a uint256. Newton's method converges quadratically (precision doubles at\n        // every iteration). We thus need at most 7 iteration to turn our partial result with one bit of precision\n        // into the expected uint128 result.\n        unchecked {\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            result = (result + a / result) >> 1;\n            return min(result, a / result);\n        }\n    }\n\n    /**\n     * @notice Calculates sqrt(a), following the selected rounding direction.\n     */\n    function sqrt(uint256 a, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = sqrt(a);\n            return result + (rounding == Rounding.Up && result * result < a ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 2, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 128;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 64;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 32;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 16;\n            }\n            if (value >> 8 > 0) {\n                value >>= 8;\n                result += 8;\n            }\n            if (value >> 4 > 0) {\n                value >>= 4;\n                result += 4;\n            }\n            if (value >> 2 > 0) {\n                value >>= 2;\n                result += 2;\n            }\n            if (value >> 1 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 2, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log2(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log2(value);\n            return result + (rounding == Rounding.Up && 1 << result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 10, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >= 10 ** 64) {\n                value /= 10 ** 64;\n                result += 64;\n            }\n            if (value >= 10 ** 32) {\n                value /= 10 ** 32;\n                result += 32;\n            }\n            if (value >= 10 ** 16) {\n                value /= 10 ** 16;\n                result += 16;\n            }\n            if (value >= 10 ** 8) {\n                value /= 10 ** 8;\n                result += 8;\n            }\n            if (value >= 10 ** 4) {\n                value /= 10 ** 4;\n                result += 4;\n            }\n            if (value >= 10 ** 2) {\n                value /= 10 ** 2;\n                result += 2;\n            }\n            if (value >= 10 ** 1) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 10, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log10(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log10(value);\n            return result + (rounding == Rounding.Up && 10 ** result < value ? 1 : 0);\n        }\n    }\n\n    /**\n     * @dev Return the log in base 256, rounded down, of a positive value.\n     * Returns 0 if given 0.\n     *\n     * Adding one to the result gives the number of pairs of hex symbols needed to represent `value` as a hex string.\n     */\n    function log256(uint256 value) internal pure returns (uint256) {\n        uint256 result = 0;\n        unchecked {\n            if (value >> 128 > 0) {\n                value >>= 128;\n                result += 16;\n            }\n            if (value >> 64 > 0) {\n                value >>= 64;\n                result += 8;\n            }\n            if (value >> 32 > 0) {\n                value >>= 32;\n                result += 4;\n            }\n            if (value >> 16 > 0) {\n                value >>= 16;\n                result += 2;\n            }\n            if (value >> 8 > 0) {\n                result += 1;\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Return the log in base 256, following the selected rounding direction, of a positive value.\n     * Returns 0 if given 0.\n     */\n    function log256(uint256 value, Rounding rounding) internal pure returns (uint256) {\n        unchecked {\n            uint256 result = log256(value);\n            return result + (rounding == Rounding.Up && 1 << (result << 3) < value ? 1 : 0);\n        }\n    }\n}\n"
      },
      "lib/composable-cow/src/types/ConditionalOrdersUtilsLib.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @title ConditionalOrdersUtilsLib - Utility functions for standardising conditional orders.\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\nlibrary ConditionalOrdersUtilsLib {\n    uint256 constant MAX_BPS = 10000;\n\n    /**\n     * Given the width of the validity bucket, return the timestamp of the *end* of the bucket.\n     * @param validity The width of the validity bucket in seconds.\n     */\n    function validToBucket(uint32 validity) internal view returns (uint32 validTo) {\n        validTo = ((uint32(block.timestamp) / validity) * validity) + validity;\n    }\n\n    /**\n     * Given a price returned by a chainlink-like oracle, scale it to the desired amount of decimals\n     * @param oraclePrice return by a chainlink-like oracle\n     * @param fromDecimals the decimals the oracle returned (e.g. 8 for USDC)\n     * @param toDecimals the amount of decimals the price should be scaled to\n     */\n    function scalePrice(int256 oraclePrice, uint8 fromDecimals, uint8 toDecimals) internal pure returns (int256) {\n        if (fromDecimals < toDecimals) {\n            return oraclePrice * int256(10 ** uint256(toDecimals - fromDecimals));\n        } else if (fromDecimals > toDecimals) {\n            return oraclePrice / int256(10 ** uint256(fromDecimals - toDecimals));\n        }\n        return oraclePrice;\n    }\n}\n"
      },
      "lib/composable-cow/src/BaseConditionalOrder.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\nimport {GPv2Order, IERC20} from \"cowprotocol/contracts/libraries/GPv2Order.sol\";\n\nimport {IERC165, IConditionalOrder, IConditionalOrderGenerator} from \"./interfaces/IConditionalOrder.sol\";\n\n// --- error strings\n/// @dev This error is returned by the `verify` function if the *generated* order hash does not match\n///      the hash passed as a parameter.\nstring constant INVALID_HASH = \"invalid hash\";\n\n/**\n * @title Base logic for conditional orders.\n * @dev Enforces the order verification logic for conditional orders, allowing developers\n *      to focus on the logic for generating the tradeable order.\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\nabstract contract BaseConditionalOrder is IConditionalOrderGenerator {\n    /**\n     * @inheritdoc IConditionalOrder\n     * @dev As an order generator, the `GPv2Order.Data` passed as a parameter is ignored / not validated.\n     */\n    function verify(\n        address owner,\n        address sender,\n        bytes32 _hash,\n        bytes32 domainSeparator,\n        bytes32 ctx,\n        bytes calldata staticInput,\n        bytes calldata offchainInput,\n        GPv2Order.Data calldata\n    ) external view override {\n        GPv2Order.Data memory generatedOrder = getTradeableOrder(owner, sender, ctx, staticInput, offchainInput);\n\n        /// @dev Verify that the *generated* order is valid and matches the payload.\n        if (!(_hash == GPv2Order.hash(generatedOrder, domainSeparator))) {\n            revert IConditionalOrder.OrderNotValid(INVALID_HASH);\n        }\n    }\n\n    /**\n     * @dev Set the visibility of this function to `public` to allow `verify` to call it.\n     * @inheritdoc IConditionalOrderGenerator\n     */\n    function getTradeableOrder(\n        address owner,\n        address sender,\n        bytes32 ctx,\n        bytes calldata staticInput,\n        bytes calldata offchainInput\n    ) public view virtual override returns (GPv2Order.Data memory);\n\n    /**\n     * @inheritdoc IERC165\n     */\n    function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {\n        return interfaceId == type(IConditionalOrderGenerator).interfaceId || interfaceId == type(IERC165).interfaceId;\n    }\n}\n"
      },
      "src/interfaces/IPriceOracle.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\n/**\n * @title CoW AMM Price Oracle Interface\n * @author CoW Protocol Developers\n * @dev A contract that can be used by the CoW AMM as as a price oracle.\n * The price source depends on the actual implementation; it could rely for\n * example on Uniswap, Balancer, Chainlink...\n */\ninterface IPriceOracle {\n    /**\n     * @dev Calling this function returns the price of token1 in terms of token0\n     * as a fraction (numerator, denominator).\n     * For example, in a pool where token0 is DAI, token1 is ETH, and ETH is\n     * worth 2000 DAI, valid output tuples would be (2000, 1), (20000, 10), ...\n     * @dev To keep the risk of multiplication overflow to a minimum, we\n     * recommend to use return values that fit the size of a uint128.\n     * @param token0 The first token, whose price is determined based on the\n     * second token.\n     * @param token1 The second token; the price of the first token is\n     * determined relative to this token.\n     * @param data Any additional data that may be required by the specific\n     * oracle implementation. For example, it could be a specific pool id for\n     * balancer, or the address of a specific price feed for Chainlink.\n     * We recommend this data be implemented as the abi-encoding of a dedicated\n     * data struct for ease of type-checking and decoding the input.\n     * @return priceNumerator The numerator of the price, expressed in amount of\n     * token1 per amount of token0.\n     * @return priceDenominator The denominator of the price, expressed in\n     * amount of token1 per amount of token0.\n     */\n    function getPrice(address token0, address token1, bytes calldata data)\n        external\n        view\n        returns (uint256 priceNumerator, uint256 priceDenominator);\n}\n"
      },
      "src/interfaces/ISettlement.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\n/**\n * @title CoW Protocol Settlement Interface\n * @author CoW Protocol Developers\n * @dev This interface collects the functions of the CoW Protocol settlement\n * contract that are used by the CoW AMM.\n */\ninterface ISettlement {\n    /**\n     * @dev The domain separator used for signing orders that gets mixed in\n     * making signatures for different domains incompatible. This domain\n     * separator is computed following the EIP-712 standard and has replay\n     * protection mixed in so that signed orders are only valid for specific\n     * GPv2 contracts.\n     */\n    function domainSeparator() external view returns (bytes32);\n\n    /**\n     * @dev The address of the vault relayer: the contract that handles\n     * withdrawing tokens from the user to the settlement contract. A user who\n     * wants to sell a token on CoW Swap must approve this contract to spend the\n     * token.\n     */\n    function vaultRelayer() external view returns (address);\n}\n"
      },
      "lib/composable-cow/lib/cowprotocol/src/contracts/libraries/GPv2Order.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\npragma solidity >=0.7.6 <0.9.0;\n\nimport \"../interfaces/IERC20.sol\";\n\n/// @title Gnosis Protocol v2 Order Library\n/// @author Gnosis Developers\nlibrary GPv2Order {\n    /// @dev The complete data for a Gnosis Protocol order. This struct contains\n    /// all order parameters that are signed for submitting to GP.\n    struct Data {\n        IERC20 sellToken;\n        IERC20 buyToken;\n        address receiver;\n        uint256 sellAmount;\n        uint256 buyAmount;\n        uint32 validTo;\n        bytes32 appData;\n        uint256 feeAmount;\n        bytes32 kind;\n        bool partiallyFillable;\n        bytes32 sellTokenBalance;\n        bytes32 buyTokenBalance;\n    }\n\n    /// @dev The order EIP-712 type hash for the [`GPv2Order.Data`] struct.\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\n    ///     \"Order(\" +\n    ///         \"address sellToken,\" +\n    ///         \"address buyToken,\" +\n    ///         \"address receiver,\" +\n    ///         \"uint256 sellAmount,\" +\n    ///         \"uint256 buyAmount,\" +\n    ///         \"uint32 validTo,\" +\n    ///         \"bytes32 appData,\" +\n    ///         \"uint256 feeAmount,\" +\n    ///         \"string kind,\" +\n    ///         \"bool partiallyFillable,\" +\n    ///         \"string sellTokenBalance,\" +\n    ///         \"string buyTokenBalance\" +\n    ///     \")\"\n    /// )\n    /// ```\n    bytes32 internal constant TYPE_HASH =\n        hex\"d5a25ba2e97094ad7d83dc28a6572da797d6b3e7fc6663bd93efb789fc17e489\";\n\n    /// @dev The marker value for a sell order for computing the order struct\n    /// hash. This allows the EIP-712 compatible wallets to display a\n    /// descriptive string for the order kind (instead of 0 or 1).\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\"sell\")\n    /// ```\n    bytes32 internal constant KIND_SELL =\n        hex\"f3b277728b3fee749481eb3e0b3b48980dbbab78658fc419025cb16eee346775\";\n\n    /// @dev The OrderKind marker value for a buy order for computing the order\n    /// struct hash.\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\"buy\")\n    /// ```\n    bytes32 internal constant KIND_BUY =\n        hex\"6ed88e868af0a1983e3886d5f3e95a2fafbd6c3450bc229e27342283dc429ccc\";\n\n    /// @dev The TokenBalance marker value for using direct ERC20 balances for\n    /// computing the order struct hash.\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\"erc20\")\n    /// ```\n    bytes32 internal constant BALANCE_ERC20 =\n        hex\"5a28e9363bb942b639270062aa6bb295f434bcdfc42c97267bf003f272060dc9\";\n\n    /// @dev The TokenBalance marker value for using Balancer Vault external\n    /// balances (in order to re-use Vault ERC20 approvals) for computing the\n    /// order struct hash.\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\"external\")\n    /// ```\n    bytes32 internal constant BALANCE_EXTERNAL =\n        hex\"abee3b73373acd583a130924aad6dc38cfdc44ba0555ba94ce2ff63980ea0632\";\n\n    /// @dev The TokenBalance marker value for using Balancer Vault internal\n    /// balances for computing the order struct hash.\n    ///\n    /// This value is pre-computed from the following expression:\n    /// ```\n    /// keccak256(\"internal\")\n    /// ```\n    bytes32 internal constant BALANCE_INTERNAL =\n        hex\"4ac99ace14ee0a5ef932dc609df0943ab7ac16b7583634612f8dc35a4289a6ce\";\n\n    /// @dev Marker address used to indicate that the receiver of the trade\n    /// proceeds should the owner of the order.\n    ///\n    /// This is chosen to be `address(0)` for gas efficiency as it is expected\n    /// to be the most common case.\n    address internal constant RECEIVER_SAME_AS_OWNER = address(0);\n\n    /// @dev The byte length of an order unique identifier.\n    uint256 internal constant UID_LENGTH = 56;\n\n    /// @dev Returns the actual receiver for an order. This function checks\n    /// whether or not the [`receiver`] field uses the marker value to indicate\n    /// it is the same as the order owner.\n    ///\n    /// @return receiver The actual receiver of trade proceeds.\n    function actualReceiver(\n        Data memory order,\n        address owner\n    ) internal pure returns (address receiver) {\n        if (order.receiver == RECEIVER_SAME_AS_OWNER) {\n            receiver = owner;\n        } else {\n            receiver = order.receiver;\n        }\n    }\n\n    /// @dev Return the EIP-712 signing hash for the specified order.\n    ///\n    /// @param order The order to compute the EIP-712 signing hash for.\n    /// @param domainSeparator The EIP-712 domain separator to use.\n    /// @return orderDigest The 32 byte EIP-712 struct hash.\n    function hash(\n        Data memory order,\n        bytes32 domainSeparator\n    ) internal pure returns (bytes32 orderDigest) {\n        bytes32 structHash;\n\n        // NOTE: Compute the EIP-712 order struct hash in place. As suggested\n        // in the EIP proposal, noting that the order struct has 12 fields, and\n        // prefixing the type hash `(1 + 12) * 32 = 416` bytes to hash.\n        // <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#rationale-for-encodedata>\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let dataStart := sub(order, 32)\n            let temp := mload(dataStart)\n            mstore(dataStart, TYPE_HASH)\n            structHash := keccak256(dataStart, 416)\n            mstore(dataStart, temp)\n        }\n\n        // NOTE: Now that we have the struct hash, compute the EIP-712 signing\n        // hash using scratch memory past the free memory pointer. The signing\n        // hash is computed from `\"\\x19\\x01\" || domainSeparator || structHash`.\n        // <https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory>\n        // <https://github.com/ethereum/EIPs/blob/master/EIPS/eip-712.md#specification>\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let freeMemoryPointer := mload(0x40)\n            mstore(freeMemoryPointer, \"\\x19\\x01\")\n            mstore(add(freeMemoryPointer, 2), domainSeparator)\n            mstore(add(freeMemoryPointer, 34), structHash)\n            orderDigest := keccak256(freeMemoryPointer, 66)\n        }\n    }\n\n    /// @dev Packs order UID parameters into the specified memory location. The\n    /// result is equivalent to `abi.encodePacked(...)` with the difference that\n    /// it allows re-using the memory for packing the order UID.\n    ///\n    /// This function reverts if the order UID buffer is not the correct size.\n    ///\n    /// @param orderUid The buffer pack the order UID parameters into.\n    /// @param orderDigest The EIP-712 struct digest derived from the order\n    /// parameters.\n    /// @param owner The address of the user who owns this order.\n    /// @param validTo The epoch time at which the order will stop being valid.\n    function packOrderUidParams(\n        bytes memory orderUid,\n        bytes32 orderDigest,\n        address owner,\n        uint32 validTo\n    ) internal pure {\n        require(orderUid.length == UID_LENGTH, \"GPv2: uid buffer overflow\");\n\n        // NOTE: Write the order UID to the allocated memory buffer. The order\n        // parameters are written to memory in **reverse order** as memory\n        // operations write 32-bytes at a time and we want to use a packed\n        // encoding. This means, for example, that after writing the value of\n        // `owner` to bytes `20:52`, writing the `orderDigest` to bytes `0:32`\n        // will **overwrite** bytes `20:32`. This is desirable as addresses are\n        // only 20 bytes and `20:32` should be `0`s:\n        //\n        //        |           1111111111222222222233333333334444444444555555\n        //   byte | 01234567890123456789012345678901234567890123456789012345\n        // -------+---------------------------------------------------------\n        //  field | [.........orderDigest..........][......owner.......][vT]\n        // -------+---------------------------------------------------------\n        // mstore |                         [000000000000000000000000000.vT]\n        //        |                     [00000000000.......owner.......]\n        //        | [.........orderDigest..........]\n        //\n        // Additionally, since Solidity `bytes memory` are length prefixed,\n        // 32 needs to be added to all the offsets.\n        //\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            mstore(add(orderUid, 56), validTo)\n            mstore(add(orderUid, 52), owner)\n            mstore(add(orderUid, 32), orderDigest)\n        }\n    }\n\n    /// @dev Extracts specific order information from the standardized unique\n    /// order id of the protocol.\n    ///\n    /// @param orderUid The unique identifier used to represent an order in\n    /// the protocol. This uid is the packed concatenation of the order digest,\n    /// the validTo order parameter and the address of the user who created the\n    /// order. It is used by the user to interface with the contract directly,\n    /// and not by calls that are triggered by the solvers.\n    /// @return orderDigest The EIP-712 signing digest derived from the order\n    /// parameters.\n    /// @return owner The address of the user who owns this order.\n    /// @return validTo The epoch time at which the order will stop being valid.\n    function extractOrderUidParams(\n        bytes calldata orderUid\n    )\n        internal\n        pure\n        returns (bytes32 orderDigest, address owner, uint32 validTo)\n    {\n        require(orderUid.length == UID_LENGTH, \"GPv2: invalid uid\");\n\n        // Use assembly to efficiently decode packed calldata.\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            orderDigest := calldataload(orderUid.offset)\n            owner := shr(96, calldataload(add(orderUid.offset, 32)))\n            validTo := shr(224, calldataload(add(orderUid.offset, 52)))\n        }\n    }\n}\n"
      },
      "lib/composable-cow/src/interfaces/IConditionalOrder.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport {GPv2Order} from \"cowprotocol/contracts/libraries/GPv2Order.sol\";\nimport {GPv2Interaction} from \"cowprotocol/contracts/libraries/GPv2Interaction.sol\";\nimport {IERC165} from \"safe/interfaces/IERC165.sol\";\n\n/**\n * @title Conditional Order Interface\n * @author CoW Protocol Developers + mfw78 <mfw78@rndlabs.xyz>\n */\ninterface IConditionalOrder {\n    /// @dev This error is returned by the `getTradeableOrder` function if the order condition is not met.\n    ///      A parameter of `string` type is included to allow the caller to specify the reason for the failure.\n    error OrderNotValid(string);\n\n    /**\n     * @dev This struct is used to uniquely identify a conditional order for an owner.\n     *      H(handler || salt || staticInput) **MUST** be unique for an owner.\n     */\n    struct ConditionalOrderParams {\n        IConditionalOrder handler;\n        bytes32 salt;\n        bytes staticInput;\n    }\n\n    /**\n     * Verify if a given discrete order is valid.\n     * @dev Used in combination with `isValidSafeSignature` to verify that the order is signed by the Safe.\n     *      **MUST** revert if the order condition is not met.\n     * @dev The `order` parameter is ignored / not validated by the `IConditionalOrderGenerator` implementation.\n     *      This parameter is included to allow more granular control over the order verification logic, and to\n     *      allow a watch tower / user to propose a discrete order without it being generated by on-chain logic.\n     * @param owner the contract who is the owner of the order\n     * @param sender the `msg.sender` of the transaction\n     * @param _hash the hash of the order\n     * @param domainSeparator the domain separator used to sign the order\n     * @param ctx the context key of the order (bytes32(0) if a merkle tree is used, otherwise H(params)) with which to lookup the cabinet\n     * @param staticInput the static input for all discrete orders cut from this conditional order\n     * @param offchainInput dynamic off-chain input for a discrete order cut from this conditional order\n     * @param order `GPv2Order.Data` of a discrete order to be verified (if *not* an `IConditionalOrderGenerator`).\n     */\n    function verify(\n        address owner,\n        address sender,\n        bytes32 _hash,\n        bytes32 domainSeparator,\n        bytes32 ctx,\n        bytes calldata staticInput,\n        bytes calldata offchainInput,\n        GPv2Order.Data calldata order\n    ) external view;\n}\n\n/**\n * @title Conditional Order Generator Interface\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\ninterface IConditionalOrderGenerator is IConditionalOrder, IERC165 {\n    /**\n     * @dev This event is emitted when a new conditional order is created.\n     * @param owner the address that has created the conditional order\n     * @param params the address / salt / data of the conditional order\n     */\n    event ConditionalOrderCreated(address indexed owner, IConditionalOrder.ConditionalOrderParams params);\n\n    /**\n     * @dev Get a tradeable order that can be posted to the CoW Protocol API and would pass signature validation.\n     *      **MUST** revert if the order condition is not met.\n     * @param owner the contract who is the owner of the order\n     * @param sender the `msg.sender` of the parent `isValidSignature` call\n     * @param ctx the context of the order (bytes32(0) if merkle tree is used, otherwise the H(params))\n     * @param staticInput the static input for all discrete orders cut from this conditional order\n     * @param offchainInput dynamic off-chain input for a discrete order cut from this conditional order\n     * @return the tradeable order for submission to the CoW Protocol API\n     */\n    function getTradeableOrder(\n        address owner,\n        address sender,\n        bytes32 ctx,\n        bytes calldata staticInput,\n        bytes calldata offchainInput\n    ) external view returns (GPv2Order.Data memory);\n}\n"
      },
      "lib/composable-cow/lib/cowprotocol/src/contracts/interfaces/IERC20.sol": {
        "content": "// SPDX-License-Identifier: MIT\n\n// Vendored from OpenZeppelin contracts with minor modifications:\n// - Modified Solidity version\n// - Formatted code\n// - Added `name`, `symbol` and `decimals` function declarations\n// <https://github.com/OpenZeppelin/openzeppelin-contracts/blob/v3.4.0/contracts/token/ERC20/IERC20.sol>\n\npragma solidity >=0.7.6 <0.9.0;\n\n/**\n * @dev Interface of the ERC20 standard as defined in the EIP.\n */\ninterface IERC20 {\n    /**\n     * @dev Returns the name of the token.\n     */\n    function name() external view returns (string memory);\n\n    /**\n     * @dev Returns the symbol of the token.\n     */\n    function symbol() external view returns (string memory);\n\n    /**\n     * @dev Returns the number of decimals the token uses.\n     */\n    function decimals() external view returns (uint8);\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 `recipient`.\n     *\n     * Returns a boolean value indicating whether the operation succeeded.\n     *\n     * Emits a {Transfer} event.\n     */\n    function transfer(\n        address recipient,\n        uint256 amount\n    ) 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(\n        address owner,\n        address spender\n    ) 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 `sender` to `recipient` 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 sender,\n        address recipient,\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"
      },
      "lib/composable-cow/lib/cowprotocol/src/contracts/libraries/GPv2Interaction.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\npragma solidity >=0.7.6 <0.9.0;\n\n/// @title Gnosis Protocol v2 Interaction Library\n/// @author Gnosis Developers\nlibrary GPv2Interaction {\n    /// @dev Interaction data for performing arbitrary contract interactions.\n    /// Submitted to [`GPv2Settlement.settle`] for code execution.\n    struct Data {\n        address target;\n        uint256 value;\n        bytes callData;\n    }\n\n    /// @dev Execute an arbitrary contract interaction.\n    ///\n    /// @param interaction Interaction data.\n    function execute(Data calldata interaction) internal {\n        address target = interaction.target;\n        uint256 value = interaction.value;\n        bytes calldata callData = interaction.callData;\n\n        // NOTE: Use assembly to call the interaction instead of a low level\n        // call for two reasons:\n        // - We don't want to copy the return data, since we discard it for\n        // interactions.\n        // - Solidity will under certain conditions generate code to copy input\n        // calldata twice to memory (the second being a \"memcopy loop\").\n        // <https://github.com/gnosis/gp-v2-contracts/pull/417#issuecomment-775091258>\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let freeMemoryPointer := mload(0x40)\n            calldatacopy(freeMemoryPointer, callData.offset, callData.length)\n            if iszero(\n                call(\n                    gas(),\n                    target,\n                    value,\n                    freeMemoryPointer,\n                    callData.length,\n                    0,\n                    0\n                )\n            ) {\n                returndatacopy(0, 0, returndatasize())\n                revert(0, returndatasize())\n            }\n        }\n    }\n\n    /// @dev Extracts the Solidity ABI selector for the specified interaction.\n    ///\n    /// @param interaction Interaction data.\n    /// @return result The 4 byte function selector of the call encoded in\n    /// this interaction.\n    function selector(\n        Data calldata interaction\n    ) internal pure returns (bytes4 result) {\n        bytes calldata callData = interaction.callData;\n        if (callData.length >= 4) {\n            // NOTE: Read the first word of the interaction's calldata. The\n            // value does not need to be shifted since `bytesN` values are left\n            // aligned, and the value does not need to be masked since masking\n            // occurs when the value is accessed and not stored:\n            // <https://docs.soliditylang.org/en/v0.7.6/abi-spec.html#encoding-of-indexed-event-parameters>\n            // <https://docs.soliditylang.org/en/v0.7.6/assembly.html#access-to-external-variables-functions-and-libraries>\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                result := calldataload(callData.offset)\n            }\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/interfaces/IERC165.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @notice More details at https://github.com/OpenZeppelin/openzeppelin-contracts/blob/master/contracts/utils/introspection/IERC165.sol\ninterface IERC165 {\n    /**\n     * @dev Returns true if this contract implements the interface defined by `interfaceId`.\n     * See the corresponding EIP section\n     * https://eips.ethereum.org/EIPS/eip-165#how-interfaces-are-identified\n     * to learn more about how these ids are created.\n     *\n     * This function call must use less than 30 000 gas.\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool);\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "lib/composable-cow:safe/=lib/composable-cow/lib/safe/contracts/",
        "lib/composable-cow:@openzeppelin/=lib/openzeppelin/contracts/",
        "lib/composable-cow:@openzeppelin/contracts/=lib/openzeppelin/contracts/",
        "lib/composable-cow:cowprotocol/=lib/composable-cow/lib/cowprotocol/src/",
        "@openzeppelin/=lib/composable-cow/lib/@openzeppelin/",
        "composable-cow/=lib/composable-cow/",
        "cowprotocol/=lib/composable-cow/lib/cowprotocol/src/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin/lib/erc4626-tests/",
        "forge-std/=lib/forge-std/src/",
        "murky/=lib/composable-cow/lib/murky/src/",
        "openzeppelin-contracts/=lib/composable-cow/lib/murky/lib/openzeppelin-contracts/",
        "openzeppelin/=lib/openzeppelin/",
        "safe/=lib/composable-cow/lib/safe/",
        "uniswap-v2-core/=lib/uniswap-v2-core/contracts/"
      ],
      "optimizer": {
        "enabled": true,
        "runs": 100000
      },
      "metadata": {
        "useLiteralContent": false,
        "bytecodeHash": "ipfs",
        "appendCBOR": true
      },
      "outputSelection": {
        "*": {
          "*": [
            "evm.bytecode",
            "evm.deployedBytecode",
            "devdoc",
            "userdoc",
            "metadata",
            "abi"
          ]
        }
      },
      "evmVersion": "cancun",
      "viaIR": false,
      "libraries": {}
    }
  }}