creation_sourcecode: {{
    "language": "Solidity",
    "sources": {
      "src/ConstantProductFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\nimport {ComposableCoW, IConditionalOrder} from \"lib/composable-cow/src/ComposableCoW.sol\";\nimport {SafeERC20} from \"lib/openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol\";\n\nimport {ConstantProduct, IERC20, 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 {\n    using SafeERC20 for IERC20;\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 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     * @param minTradedToken0 The minimum amount of token0 before the AMM\n     * attempts auto-rebalance.\n     * @param priceOracle The address of the price oracle to use for the AMM.\n     * @param priceOracleData The data to pass to the price oracle.\n     * @param appData The app data to pass to the AMM.\n     * @return amm The address of the newly deployed AMM.\n     */\n    function create(\n        IERC20 token0,\n        uint256 amount0,\n        IERC20 token1,\n        uint256 amount1,\n        uint256 minTradedToken0,\n        IPriceOracle priceOracle,\n        bytes calldata priceOracleData,\n        bytes32 appData\n    ) external returns (ConstantProduct amm) {\n        address ammOwner = msg.sender;\n        amm = new ConstantProduct{salt: salt(ammOwner)}(settler, token0, token1);\n        emit Deployed(amm, ammOwner, token0, token1);\n        owner[amm] = ammOwner;\n\n        deposit(amm, amount0, amount1);\n\n        ConstantProduct.TradingParams memory data = ConstantProduct.TradingParams({\n            minTradedToken0: minTradedToken0,\n            priceOracle: priceOracle,\n            priceOracleData: priceOracleData,\n            appData: appData\n        });\n        _enableTrading(amm, data);\n    }\n\n    /**\n     * @notice Change the parameters used for trading on the specified AMM. Only\n     * a single order per AMM can be valid at a time, meaning that any previous\n     * order stops being tradeable.\n     * @param amm The address of the AMM whose parameters to change.\n     * @param minTradedToken0 The minimum amount of token0 before the AMM\n     * attempts auto-rebalance.\n     * @param priceOracle The address of the price oracle to use for the AMM.\n     * @param priceOracleData The data to pass to the price oracle.\n     * @param appData The app data to pass to the AMM.\n     */\n    function updateParameters(\n        ConstantProduct amm,\n        uint256 minTradedToken0,\n        IPriceOracle priceOracle,\n        bytes calldata priceOracleData,\n        bytes32 appData\n    ) external onlyOwner(amm) {\n        ConstantProduct.TradingParams memory data = ConstantProduct.TradingParams({\n            minTradedToken0: minTradedToken0,\n            priceOracle: priceOracle,\n            priceOracleData: priceOracleData,\n            appData: appData\n        });\n        _disableTrading(amm);\n        _enableTrading(amm, data);\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        amm.token0().safeTransferFrom(address(amm), msg.sender, amount0);\n        amm.token1().safeTransferFrom(address(amm), msg.sender, amount1);\n    }\n\n    /**\n     * @notice This function exists to let the watchtower off-chain service\n     * automatically create AMM orders and post them on the orderbook. It\n     * outputs an order for the input AMM together with a valid signature.\n     * @dev Some parameters are unused as they refer to features of\n     * ComposableCoW that aren't implemented in this contract. They are still\n     * needed to let the watchtower interact with this contract in the same way\n     * as ComposableCoW.\n     * @param amm owner of the order.\n     * @param params `ConditionalOrderParams` for the order; precisely, the\n     * handler must be this contract, the salt can be any value, and the static\n     * input must be the current trading parameters of the AMM.\n     * @return order discrete order for submitting to CoW Protocol API\n     * @return signature for submitting to CoW Protocol API\n     */\n    function getTradeableOrderWithSignature(\n        ConstantProduct amm,\n        IConditionalOrder.ConditionalOrderParams calldata params,\n        bytes calldata, // offchainInput\n        bytes32[] calldata // proof\n    ) external view returns (GPv2Order.Data memory order, bytes memory signature) {\n        // This contract mimics the interface of ConditionalCoW to talk to the\n        // watchtower. In principle we'd still get a valid order if the handler\n        // is set to any address. However, we create conditional orders on this\n        // contract with this contract as the handler, so to make sure that the\n        // user isn't trying to forward this order to the incorrect contract,\n        // we revert with this error message.\n        if (address(params.handler) != address(this)) {\n            revert IConditionalOrder.OrderNotValid(\"can only handle own orders\");\n        }\n\n        ConstantProduct.TradingParams memory tradingParams =\n            abi.decode(params.staticInput, (ConstantProduct.TradingParams));\n\n        // Check that `getTradeableOrderWithSignature` is being called with\n        // parameters that are currently enabled for trading on the AMM.\n        // If the parameters are different, this order can be deleted on the\n        // watchtower.\n        if (amm.hash(tradingParams) != amm.tradingParamsHash()) {\n            revert IConditionalOrder.OrderNotValid(\"invalid trading parameters\");\n        }\n\n        // Note: the salt in params is ignored.\n\n        order = amm.getTradeableOrder(tradingParams);\n        signature = abi.encode(order, tradingParams);\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        amm.token0().safeTransferFrom(msg.sender, address(amm), amount0);\n        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     * @param tradingParams The parameters used by the CoW AMM to create the\n     * order.\n     */\n    function _enableTrading(ConstantProduct amm, ConstantProduct.TradingParams memory tradingParams) internal {\n        amm.enableTrading(tradingParams);\n        // The salt is unused by this contract. External tools (for example the\n        // watch tower) may expect that the salt doesn't repeat. However, there\n        // can be at most one valid order per AMM at a time, and any conflicting\n        // order would have been invalidated before a conflict can occur.\n        bytes32 conditionalOrderSalt = bytes32(0);\n        // The following event will be pickd up by the watchtower offchain\n        // service, which is responsible for automatically posting CoW AMM\n        // orders on the CoW Protocol orderbook.\n        emit ComposableCoW.ConditionalOrderCreated(\n            address(amm),\n            IConditionalOrder.ConditionalOrderParams(\n                IConditionalOrder(address(this)), conditionalOrderSalt, abi.encode(tradingParams)\n            )\n        );\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/composable-cow/src/ComposableCoW.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport {MerkleProof} from \"@openzeppelin/contracts/utils/cryptography/MerkleProof.sol\";\nimport \"safe/handler/ExtensibleFallbackHandler.sol\";\n\nimport \"./interfaces/IConditionalOrder.sol\";\nimport \"./interfaces/ISwapGuard.sol\";\nimport \"./interfaces/IValueFactory.sol\";\nimport \"./vendored/CoWSettlement.sol\";\n\n/**\n * @title ComposableCoW - A contract that allows users to create multiple conditional orders\n * @author mfw78 <mfw78@rndlabs.xyz>\n * @dev Designed to be used with Safe + ExtensibleFallbackHandler\n */\ncontract ComposableCoW is ISafeSignatureVerifier {\n    // --- errors\n    error ProofNotAuthed();\n    error SingleOrderNotAuthed();\n    error SwapGuardRestricted();\n    error InvalidHandler();\n    error InvalidFallbackHandler();\n    error InterfaceNotSupported();\n\n    // --- types\n\n    // A struct to encapsulate order parameters / offchain input\n    struct PayloadStruct {\n        bytes32[] proof;\n        IConditionalOrder.ConditionalOrderParams params;\n        bytes offchainInput;\n    }\n\n    // A struct representing where to find the proofs\n    struct Proof {\n        uint256 location;\n        bytes data;\n    }\n\n    // --- events\n\n    // An event emitted when a user sets their merkle root\n    event MerkleRootSet(address indexed owner, bytes32 root, Proof proof);\n    event ConditionalOrderCreated(address indexed owner, IConditionalOrder.ConditionalOrderParams params);\n    event SwapGuardSet(address indexed owner, ISwapGuard swapGuard);\n\n    // --- state\n    // Domain separator is only used for generating signatures\n    bytes32 public immutable domainSeparator;\n    /// @dev Mapping of owner's merkle roots\n    mapping(address => bytes32) public roots;\n    /// @dev Mapping of owner's single orders\n    mapping(address => mapping(bytes32 => bool)) public singleOrders;\n    // @dev Mapping of owner's swap guard\n    mapping(address => ISwapGuard) public swapGuards;\n    // @dev Mapping of owner's on-chain storage slots\n    mapping(address => mapping(bytes32 => bytes32)) public cabinet;\n\n    // --- constructor\n\n    /**\n     * @param _settlement The GPv2 settlement contract\n     */\n    constructor(address _settlement) {\n        domainSeparator = CoWSettlement(_settlement).domainSeparator();\n    }\n\n    // --- setters\n\n    /**\n     * Set the merkle root of the user's conditional orders\n     * @notice Set the merkle root of the user's conditional orders\n     * @param root The merkle root of the user's conditional orders\n     * @param proof Where to find the proofs\n     */\n    function setRoot(bytes32 root, Proof calldata proof) public {\n        roots[msg.sender] = root;\n        emit MerkleRootSet(msg.sender, root, proof);\n    }\n\n    /**\n     * Set the merkle root of the user's conditional orders and store a value from on-chain in the cabinet\n     * @param root The merkle root of the user's conditional orders\n     * @param proof Where to find the proofs\n     * @param factory A factory from which to get a value to store in the cabinet related to the merkle root\n     * @param data Implementation specific off-chain data\n     */\n    function setRootWithContext(bytes32 root, Proof calldata proof, IValueFactory factory, bytes calldata data)\n        external\n    {\n        setRoot(root, proof);\n\n        // Default to the zero slot for a merkle root as this is the most common use case\n        // and should save gas on calldata when reading the cabinet.\n\n        // Set the cabinet slot\n        cabinet[msg.sender][bytes32(0)] = factory.getValue(data);\n    }\n\n    /**\n     * Authorise a single conditional order\n     * @param params The parameters of the conditional order\n     * @param dispatch Whether to dispatch the `ConditionalOrderCreated` event\n     */\n    function create(IConditionalOrder.ConditionalOrderParams calldata params, bool dispatch) public {\n        if (!(address(params.handler) != address(0))) {\n            revert InvalidHandler();\n        }\n\n        singleOrders[msg.sender][hash(params)] = true;\n        if (dispatch) {\n            emit ConditionalOrderCreated(msg.sender, params);\n        }\n    }\n\n    /**\n     * Authorise a single conditional order and store a value from on-chain in the cabinet\n     * @param params The parameters of the conditional order\n     * @param factory A factory from which to get a value to store in the cabinet\n     * @param data Implementation specific off-chain data\n     * @param dispatch Whether to dispatch the `ConditionalOrderCreated` event\n     */\n    function createWithContext(\n        IConditionalOrder.ConditionalOrderParams calldata params,\n        IValueFactory factory,\n        bytes calldata data,\n        bool dispatch\n    ) external {\n        create(params, dispatch);\n\n        // When setting the slot, an opinionated direction is taken to tie the return value of\n        // the slot to the conditional order, such that there is a guarantee or data integrity\n\n        // Set the cabinet slot\n        cabinet[msg.sender][hash(params)] = factory.getValue(data);\n    }\n\n    /**\n     * Remove the authorisation of a single conditional order\n     * @param singleOrderHash The hash of the single conditional order to remove\n     */\n    function remove(bytes32 singleOrderHash) external {\n        singleOrders[msg.sender][singleOrderHash] = false;\n        cabinet[msg.sender][singleOrderHash] = bytes32(0);\n    }\n\n    /**\n     * Set the swap guard of the user's conditional orders\n     * @param swapGuard The address of the swap guard\n     */\n    function setSwapGuard(ISwapGuard swapGuard) external {\n        swapGuards[msg.sender] = swapGuard;\n        emit SwapGuardSet(msg.sender, swapGuard);\n    }\n\n    // --- ISafeSignatureVerifier\n\n    /**\n     * @inheritdoc ISafeSignatureVerifier\n     * @dev This function does not make use of the `typeHash` parameter as CoW Protocol does not\n     *      have more than one type.\n     * @param encodeData Is the abi encoded `GPv2Order.Data`\n     * @param payload Is the abi encoded `PayloadStruct`\n     */\n    function isValidSafeSignature(\n        Safe safe,\n        address sender,\n        bytes32 _hash,\n        bytes32 _domainSeparator,\n        bytes32, // typeHash\n        bytes calldata encodeData,\n        bytes calldata payload\n    ) external view override returns (bytes4 magic) {\n        // First decode the payload\n        PayloadStruct memory _payload = abi.decode(payload, (PayloadStruct));\n\n        // Check if the order is authorised\n        bytes32 ctx = _auth(address(safe), _payload.params, _payload.proof);\n\n        // It's an authorised order, validate it.\n        GPv2Order.Data memory order = abi.decode(encodeData, (GPv2Order.Data));\n\n        // Check with the swap guard if the order is restricted or not\n        if (!(_guardCheck(address(safe), ctx, _payload.params, _payload.offchainInput, order))) {\n            revert SwapGuardRestricted();\n        }\n\n        // Proof is valid, guard (if any) is valid, now check the handler\n        _payload.params.handler.verify(\n            address(safe),\n            sender,\n            _hash,\n            _domainSeparator,\n            ctx,\n            _payload.params.staticInput,\n            _payload.offchainInput,\n            order\n        );\n\n        return ERC1271.isValidSignature.selector;\n    }\n\n    // --- getters\n\n    /**\n     * Get the `GPv2Order.Data` and signature for submitting to CoW Protocol API\n     * @param owner of the order\n     * @param params `ConditionalOrderParams` for the order\n     * @param offchainInput any dynamic off-chain input for generating the discrete order\n     * @param proof if using merkle-roots that H(handler || salt || staticInput) is in the merkle tree\n     * @return order discrete order for submitting to CoW Protocol API\n     * @return signature for submitting to CoW Protocol API\n     */\n    function getTradeableOrderWithSignature(\n        address owner,\n        IConditionalOrder.ConditionalOrderParams calldata params,\n        bytes calldata offchainInput,\n        bytes32[] calldata proof\n    ) external view returns (GPv2Order.Data memory order, bytes memory signature) {\n        // Check if the order is authorised and in doing so, get the context\n        bytes32 ctx = _auth(owner, params, proof);\n\n        // Make sure the handler supports `IConditionalOrderGenerator`\n        try IConditionalOrderGenerator(address(params.handler)).supportsInterface(\n            type(IConditionalOrderGenerator).interfaceId\n        ) returns (bool supported) {\n            if (!supported) {\n                revert InterfaceNotSupported();\n            }\n        } catch {\n            revert InterfaceNotSupported();\n        }\n\n        order = IConditionalOrderGenerator(address(params.handler)).getTradeableOrder(\n            owner, msg.sender, ctx, params.staticInput, offchainInput\n        );\n\n        // Check with the swap guard if the order is restricted or not\n        if (!(_guardCheck(owner, ctx, params, offchainInput, order))) {\n            revert SwapGuardRestricted();\n        }\n\n        try ExtensibleFallbackHandler(owner).supportsInterface(type(ISignatureVerifierMuxer).interfaceId) returns (\n            bool supported\n        ) {\n            if (!supported) {\n                revert InvalidFallbackHandler();\n            }\n            signature = abi.encodeWithSignature(\n                \"safeSignature(bytes32,bytes32,bytes,bytes)\",\n                domainSeparator,\n                GPv2Order.TYPE_HASH,\n                abi.encode(order),\n                abi.encode(PayloadStruct({params: params, offchainInput: offchainInput, proof: proof}))\n            );\n        } catch {\n            // Assume that this is the EIP-1271 Forwarder (which does not have a `NAME` function)\n            // The default signature is the abi.encode of the tuple (order, payload)\n            signature = abi.encode(order, PayloadStruct({params: params, offchainInput: offchainInput, proof: proof}));\n        }\n    }\n\n    // --- helper viewer functions\n\n    /**\n     * Return the hash of the conditional order parameters\n     * @param params `ConditionalOrderParams` for the order\n     * @return hash of the conditional order parameters\n     */\n    function hash(IConditionalOrder.ConditionalOrderParams memory params) public pure returns (bytes32) {\n        return keccak256(abi.encode(params));\n    }\n\n    // --- internal functions\n\n    /**\n     * Check if the order has been authorised by the owner\n     * @dev If `proof.length == 0`, then we use the single order auth\n     * @param owner of the order whose authorisation is being checked\n     * @param params that uniquely identify the order\n     * @param proof to assert that H(params) is in the merkle tree (optional)\n     */\n    function _auth(address owner, IConditionalOrder.ConditionalOrderParams memory params, bytes32[] memory proof)\n        internal\n        view\n        returns (bytes32 ctx)\n    {\n        if (proof.length != 0) {\n            /// @dev Computing proof using leaf double hashing\n            bytes32 leaf = keccak256(bytes.concat(hash(params)));\n\n            // Check if the proof is valid\n            if (!MerkleProof.verify(proof, roots[owner], leaf)) {\n                revert ProofNotAuthed();\n            }\n        } else {\n            // Check if the order is authorised\n            ctx = hash(params);\n            if (!singleOrders[owner][ctx]) {\n                revert SingleOrderNotAuthed();\n            }\n        }\n    }\n\n    /**\n     * Check the swap guard if the order is restricted or not\n     * @param owner who's swap guard to check\n     * @param ctx of the order (bytes32(0) if a merkle tree is used, otherwise H(params))\n     * @param params that uniquely identify the order\n     * @param offchainInput that has been proposed by `sender`\n     * @param order GPv2Order.Data that has been proposed by `sender`\n     */\n    function _guardCheck(\n        address owner,\n        bytes32 ctx,\n        IConditionalOrder.ConditionalOrderParams memory params,\n        bytes memory offchainInput,\n        GPv2Order.Data memory order\n    ) internal view returns (bool) {\n        ISwapGuard guard = swapGuards[owner];\n        if (address(guard) != address(0)) {\n            return guard.verify(order, ctx, params, offchainInput);\n        }\n        return true;\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/ConstantProduct.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\nimport {IERC20} 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} from \"lib/composable-cow/src/BaseConditionalOrder.sol\";\n\nimport {IPriceOracle} from \"./interfaces/IPriceOracle.sol\";\nimport {ISettlement} from \"./interfaces/ISettlement.sol\";\nimport {IWatchtowerCustomErrors} from \"./interfaces/IWatchtowerCustomErrors.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 IERC20;\n    using GPv2Order for GPv2Order.Data;\n\n    /// All data used by an order to validate the AMM conditions.\n    struct TradingParams {\n        /// The minimum amount of token0 that needs to be traded for an order\n        /// to be created on getTradeableOrder.\n        uint256 minTradedToken0;\n        /// An onchain source for the price of the two tokens. The price should\n        /// be expressed in terms of amount of token0 per amount of token1.\n        IPriceOracle priceOracle;\n        /// The data that needs to be provided to the price oracle to retrieve\n        /// the relative price of the two tokens.\n        bytes priceOracleData;\n        /// The app data that must be used in the order.\n        /// See `GPv2Order.Data` for more information on the app data.\n        bytes32 appData;\n    }\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 value representing that no trading parameters are currently\n     * accepted as valid by this contract, meaning that no trading can occur.\n     */\n    bytes32 public constant NO_TRADING = 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    /**\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     * The hash of the data describing which `TradingParams` currently apply\n     * to this AMM. If this parameter is set to `NO_TRADING`, then the AMM\n     * does not accept any order as valid.\n     * If trading is enabled, then this value will be the [`hash`] of the only\n     * admissible [`TradingParams`].\n     */\n    bytes32 public tradingParamsHash;\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     * @param hash The hash of the trading parameters.\n     * @param params Trading has been enabled for these parameters.\n     */\n    event TradingEnabled(bytes32 indexed hash, TradingParams params);\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     * @notice The order trade parameters that were provided during signature\n     * verification does not match the data stored in this contract _or_ the\n     * AMM has not enabled trading.\n     */\n    error TradingParamsDoNotMatchHash();\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     * @param tradingParams Trading is enabled with the parameters specified\n     * here.\n     */\n    function enableTrading(TradingParams calldata tradingParams) external onlyManager {\n        bytes32 _tradingParamsHash = hash(tradingParams);\n        tradingParamsHash = _tradingParamsHash;\n        emit TradingEnabled(_tradingParamsHash, tradingParams);\n    }\n\n    /**\n     * @notice Disable any form of trading on CoW Protocol by this AMM.\n     */\n    function disableTrading() external onlyManager {\n        tradingParamsHash = NO_TRADING;\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, TradingParams memory tradingParams) =\n            abi.decode(signature, (GPv2Order.Data, TradingParams));\n\n        if (hash(tradingParams) != tradingParamsHash) {\n            revert TradingParamsDoNotMatchHash();\n        }\n        bytes32 orderHash = order.hash(solutionSettlerDomainSeparator);\n        if (orderHash != _hash) {\n            revert OrderDoesNotMatchMessageHash();\n        }\n\n        requireMatchingCommitment(orderHash, tradingParams, order);\n\n        verify(tradingParams, 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 The order returned by this function is the order that needs to be\n     * executed for the price on this AMM to match that of the reference pair.\n     * @param tradingParams the trading parameters of all discrete orders cut\n     * from this AMM\n     * @return order the tradeable order for submission to the CoW Protocol API\n     */\n    function getTradeableOrder(TradingParams memory tradingParams) public view returns (GPv2Order.Data memory order) {\n        (uint256 priceNumerator, uint256 priceDenominator) =\n            tradingParams.priceOracle.getPrice(address(token0), address(token1), tradingParams.priceOracleData);\n        (uint256 selfReserve0, uint256 selfReserve1) =\n            (token0.balanceOf(address(this)), token1.balanceOf(address(this)));\n\n        IERC20 sellToken;\n        IERC20 buyToken;\n        uint256 sellAmount;\n        uint256 buyAmount;\n        // Note on rounding: we want to round down the sell amount and up the\n        // buy amount. This is because the math for the order makes it lie\n        // precisely on the AMM curve, and a rounding error to the other way\n        // could cause a valid order to become invalid.\n        // Note on the if condition: it guarantees that sellAmount is positive\n        // in the corresponding branch (it would be negative in the other). This\n        // excludes rounding errors: in this case, the function could revert but\n        // the amounts involved would be just a few atoms, so we accept that no\n        // order will be available.\n        // Note on the order price: The buy amount is not optimal for the AMM\n        // given the sell amount. This is intended because we want to force\n        // solvers to maximize the surplus for this order with the price that\n        // isn't the AMM best price.\n        uint256 selfReserve0TimesPriceDenominator = selfReserve0 * priceDenominator;\n        uint256 selfReserve1TimesPriceNumerator = selfReserve1 * priceNumerator;\n        uint256 tradedAmountToken0;\n        if (selfReserve1TimesPriceNumerator < selfReserve0TimesPriceDenominator) {\n            sellToken = token0;\n            buyToken = token1;\n            sellAmount = sub(selfReserve0 / 2, Math.ceilDiv(selfReserve1TimesPriceNumerator, 2 * priceDenominator));\n            buyAmount = Math.mulDiv(\n                sellAmount,\n                selfReserve1TimesPriceNumerator + (priceDenominator * sellAmount),\n                priceNumerator * selfReserve0,\n                Math.Rounding.Up\n            );\n            tradedAmountToken0 = sellAmount;\n        } else {\n            sellToken = token1;\n            buyToken = token0;\n            sellAmount = sub(selfReserve1 / 2, Math.ceilDiv(selfReserve0TimesPriceDenominator, 2 * priceNumerator));\n            buyAmount = Math.mulDiv(\n                sellAmount,\n                selfReserve0TimesPriceDenominator + (priceNumerator * sellAmount),\n                priceDenominator * selfReserve1,\n                Math.Rounding.Up\n            );\n            tradedAmountToken0 = buyAmount;\n        }\n\n        if (tradedAmountToken0 < tradingParams.minTradedToken0) {\n            revertPollAtNextBlock(\"traded amount too small\");\n        }\n\n        order = GPv2Order.Data(\n            sellToken,\n            buyToken,\n            GPv2Order.RECEIVER_SAME_AS_OWNER,\n            sellAmount,\n            buyAmount,\n            Utils.validToBucket(MAX_ORDER_DURATION),\n            tradingParams.appData,\n            0,\n            GPv2Order.KIND_SELL,\n            true,\n            GPv2Order.BALANCE_ERC20,\n            GPv2Order.BALANCE_ERC20\n        );\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 tradingParams the trading parameters of all discrete orders cut\n     * from this AMM\n     * @param order `GPv2Order.Data` of a discrete order to be verified.\n     */\n    function verify(TradingParams memory tradingParams, 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 != tradingParams.appData) {\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        token.safeApprove(spender, type(uint256).max);\n    }\n\n    /**\n     * @dev Computes the difference between the two input values. If it detects\n     * an underflow, the function reverts with a custom error that informs the\n     * watchtower to poll next.\n     * If the function reverted with a standard underflow, the watchtower would\n     * stop polling the order.\n     * @param lhs The minuend of the subtraction\n     * @param rhs The subtrahend of the subtraction\n     * @return The difference of the two input values\n     */\n    function sub(uint256 lhs, uint256 rhs) internal view returns (uint256) {\n        if (lhs < rhs) {\n            revertPollAtNextBlock(\"subtraction underflow\");\n        }\n        unchecked {\n            return lhs - rhs;\n        }\n    }\n\n    /**\n     * @dev Reverts call execution with a custom error that indicates to the\n     * watchtower to poll for new order when the next block is mined.\n     */\n    function revertPollAtNextBlock(string memory message) internal view {\n        revert IWatchtowerCustomErrors.PollTryAtBlock(block.number + 1, message);\n    }\n\n    /**\n     * @notice This function triggers a revert if either (1) the order hash does\n     * not match the current commitment, or (2) in the case of a commitment to\n     * `EMPTY_COMMITMENT`, the non-constant parameters of the order from\n     * `getTradeableOrder` don't match those of the input order.\n     * @param orderHash the hash of the current order as defined by the\n     * `GPv2Order` library.\n     * @param tradingParams the trading parameters of all discrete orders cut\n     * from this AMM\n     * @param order `GPv2Order.Data` of a discrete order to be verified\n     */\n    function requireMatchingCommitment(\n        bytes32 orderHash,\n        TradingParams memory tradingParams,\n        GPv2Order.Data memory order\n    ) internal view {\n        bytes32 committedOrderHash = commitment();\n\n        if (orderHash != committedOrderHash) {\n            if (committedOrderHash != EMPTY_COMMITMENT) {\n                revert OrderDoesNotMatchCommitmentHash();\n            }\n            GPv2Order.Data memory computedOrder = getTradeableOrder(tradingParams);\n            if (!matchFreeOrderParams(order, computedOrder)) {\n                revert OrderDoesNotMatchDefaultTradeableOrder();\n            }\n        }\n    }\n\n    /**\n     * @dev Computes an identifier that uniquely represents the parameters in\n     * the function input parameters.\n     * @param tradingParams Bytestring that decodes to `TradingParams`\n     * @return The hash of the input parameter, intended to be used as a unique\n     * identifier\n     */\n    function hash(TradingParams memory tradingParams) public pure returns (bytes32) {\n        return keccak256(abi.encode(tradingParams));\n    }\n\n    /**\n     * @notice Check if the parameters of the two input orders are the same,\n     * with the exception of those parameters that have a single possible value\n     * that passes the validation of `verify`.\n     * @param lhs a CoW Swap order\n     * @param rhs another CoW Swap order\n     * @return true if the order parameters match, false otherwise\n     */\n    function matchFreeOrderParams(GPv2Order.Data memory lhs, GPv2Order.Data memory rhs) internal pure returns (bool) {\n        bool sameSellToken = lhs.sellToken == rhs.sellToken;\n        bool sameBuyToken = lhs.buyToken == rhs.buyToken;\n        bool sameSellAmount = lhs.sellAmount == rhs.sellAmount;\n        bool sameBuyAmount = lhs.buyAmount == rhs.buyAmount;\n        bool sameValidTo = lhs.validTo == rhs.validTo;\n        bool sameKind = lhs.kind == rhs.kind;\n        bool samePartiallyFillable = lhs.partiallyFillable == rhs.partiallyFillable;\n\n        // The following parameters are untested:\n        // - receiver\n        // - appData\n        // - feeAmount\n        // - sellTokenBalance\n        // - buyTokenBalance\n\n        return sameSellToken && sameBuyToken && sameSellAmount && sameBuyAmount && sameValidTo && sameKind\n            && samePartiallyFillable;\n    }\n}\n"
      },
      "lib/openzeppelin/contracts/utils/cryptography/MerkleProof.sol": {
        "content": "// SPDX-License-Identifier: MIT\n// OpenZeppelin Contracts (last updated v4.9.2) (utils/cryptography/MerkleProof.sol)\n\npragma solidity ^0.8.0;\n\n/**\n * @dev These functions deal with verification of Merkle Tree proofs.\n *\n * The tree and the proofs can be generated using our\n * https://github.com/OpenZeppelin/merkle-tree[JavaScript library].\n * You will find a quickstart guide in the readme.\n *\n * WARNING: You should avoid using leaf values that are 64 bytes long prior to\n * hashing, or use a hash function other than keccak256 for hashing leaves.\n * This is because the concatenation of a sorted pair of internal nodes in\n * the merkle tree could be reinterpreted as a leaf value.\n * OpenZeppelin's JavaScript library generates merkle trees that are safe\n * against this attack out of the box.\n */\nlibrary MerkleProof {\n    /**\n     * @dev Returns true if a `leaf` can be proved to be a part of a Merkle tree\n     * defined by `root`. For this, a `proof` must be provided, containing\n     * sibling hashes on the branch from the leaf to the root of the tree. Each\n     * pair of leaves and each pair of pre-images are assumed to be sorted.\n     */\n    function verify(bytes32[] memory proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {\n        return processProof(proof, leaf) == root;\n    }\n\n    /**\n     * @dev Calldata version of {verify}\n     *\n     * _Available since v4.7._\n     */\n    function verifyCalldata(bytes32[] calldata proof, bytes32 root, bytes32 leaf) internal pure returns (bool) {\n        return processProofCalldata(proof, leaf) == root;\n    }\n\n    /**\n     * @dev Returns the rebuilt hash obtained by traversing a Merkle tree up\n     * from `leaf` using `proof`. A `proof` is valid if and only if the rebuilt\n     * hash matches the root of the tree. When processing the proof, the pairs\n     * of leafs & pre-images are assumed to be sorted.\n     *\n     * _Available since v4.4._\n     */\n    function processProof(bytes32[] memory proof, bytes32 leaf) internal pure returns (bytes32) {\n        bytes32 computedHash = leaf;\n        for (uint256 i = 0; i < proof.length; i++) {\n            computedHash = _hashPair(computedHash, proof[i]);\n        }\n        return computedHash;\n    }\n\n    /**\n     * @dev Calldata version of {processProof}\n     *\n     * _Available since v4.7._\n     */\n    function processProofCalldata(bytes32[] calldata proof, bytes32 leaf) internal pure returns (bytes32) {\n        bytes32 computedHash = leaf;\n        for (uint256 i = 0; i < proof.length; i++) {\n            computedHash = _hashPair(computedHash, proof[i]);\n        }\n        return computedHash;\n    }\n\n    /**\n     * @dev Returns true if the `leaves` can be simultaneously proven to be a part of a merkle tree defined by\n     * `root`, according to `proof` and `proofFlags` as described in {processMultiProof}.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function multiProofVerify(\n        bytes32[] memory proof,\n        bool[] memory proofFlags,\n        bytes32 root,\n        bytes32[] memory leaves\n    ) internal pure returns (bool) {\n        return processMultiProof(proof, proofFlags, leaves) == root;\n    }\n\n    /**\n     * @dev Calldata version of {multiProofVerify}\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function multiProofVerifyCalldata(\n        bytes32[] calldata proof,\n        bool[] calldata proofFlags,\n        bytes32 root,\n        bytes32[] memory leaves\n    ) internal pure returns (bool) {\n        return processMultiProofCalldata(proof, proofFlags, leaves) == root;\n    }\n\n    /**\n     * @dev Returns the root of a tree reconstructed from `leaves` and sibling nodes in `proof`. The reconstruction\n     * proceeds by incrementally reconstructing all inner nodes by combining a leaf/inner node with either another\n     * leaf/inner node or a proof sibling node, depending on whether each `proofFlags` item is true or false\n     * respectively.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. To use multiproofs, it is sufficient to ensure that: 1) the tree\n     * is complete (but not necessarily perfect), 2) the leaves to be proven are in the opposite order they are in the\n     * tree (i.e., as seen from right to left starting at the deepest layer and continuing at the next layer).\n     *\n     * _Available since v4.7._\n     */\n    function processMultiProof(\n        bytes32[] memory proof,\n        bool[] memory proofFlags,\n        bytes32[] memory leaves\n    ) internal pure returns (bytes32 merkleRoot) {\n        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by\n        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n        // the merkle tree.\n        uint256 leavesLen = leaves.length;\n        uint256 proofLen = proof.length;\n        uint256 totalHashes = proofFlags.length;\n\n        // Check proof validity.\n        require(leavesLen + proofLen - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n        // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n        bytes32[] memory hashes = new bytes32[](totalHashes);\n        uint256 leafPos = 0;\n        uint256 hashPos = 0;\n        uint256 proofPos = 0;\n        // At each step, we compute the next hash using two values:\n        // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n        //   get the next hash.\n        // - depending on the flag, either another value from the \"main queue\" (merging branches) or an element from the\n        //   `proof` array.\n        for (uint256 i = 0; i < totalHashes; i++) {\n            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n            bytes32 b = proofFlags[i]\n                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])\n                : proof[proofPos++];\n            hashes[i] = _hashPair(a, b);\n        }\n\n        if (totalHashes > 0) {\n            require(proofPos == proofLen, \"MerkleProof: invalid multiproof\");\n            unchecked {\n                return hashes[totalHashes - 1];\n            }\n        } else if (leavesLen > 0) {\n            return leaves[0];\n        } else {\n            return proof[0];\n        }\n    }\n\n    /**\n     * @dev Calldata version of {processMultiProof}.\n     *\n     * CAUTION: Not all merkle trees admit multiproofs. See {processMultiProof} for details.\n     *\n     * _Available since v4.7._\n     */\n    function processMultiProofCalldata(\n        bytes32[] calldata proof,\n        bool[] calldata proofFlags,\n        bytes32[] memory leaves\n    ) internal pure returns (bytes32 merkleRoot) {\n        // This function rebuilds the root hash by traversing the tree up from the leaves. The root is rebuilt by\n        // consuming and producing values on a queue. The queue starts with the `leaves` array, then goes onto the\n        // `hashes` array. At the end of the process, the last hash in the `hashes` array should contain the root of\n        // the merkle tree.\n        uint256 leavesLen = leaves.length;\n        uint256 proofLen = proof.length;\n        uint256 totalHashes = proofFlags.length;\n\n        // Check proof validity.\n        require(leavesLen + proofLen - 1 == totalHashes, \"MerkleProof: invalid multiproof\");\n\n        // The xxxPos values are \"pointers\" to the next value to consume in each array. All accesses are done using\n        // `xxx[xxxPos++]`, which return the current value and increment the pointer, thus mimicking a queue's \"pop\".\n        bytes32[] memory hashes = new bytes32[](totalHashes);\n        uint256 leafPos = 0;\n        uint256 hashPos = 0;\n        uint256 proofPos = 0;\n        // At each step, we compute the next hash using two values:\n        // - a value from the \"main queue\". If not all leaves have been consumed, we get the next leaf, otherwise we\n        //   get the next hash.\n        // - depending on the flag, either another value from the \"main queue\" (merging branches) or an element from the\n        //   `proof` array.\n        for (uint256 i = 0; i < totalHashes; i++) {\n            bytes32 a = leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++];\n            bytes32 b = proofFlags[i]\n                ? (leafPos < leavesLen ? leaves[leafPos++] : hashes[hashPos++])\n                : proof[proofPos++];\n            hashes[i] = _hashPair(a, b);\n        }\n\n        if (totalHashes > 0) {\n            require(proofPos == proofLen, \"MerkleProof: invalid multiproof\");\n            unchecked {\n                return hashes[totalHashes - 1];\n            }\n        } else if (leavesLen > 0) {\n            return leaves[0];\n        } else {\n            return proof[0];\n        }\n    }\n\n    function _hashPair(bytes32 a, bytes32 b) private pure returns (bytes32) {\n        return a < b ? _efficientHash(a, b) : _efficientHash(b, a);\n    }\n\n    function _efficientHash(bytes32 a, bytes32 b) private pure returns (bytes32 value) {\n        /// @solidity memory-safe-assembly\n        assembly {\n            mstore(0x00, a)\n            mstore(0x20, b)\n            value := keccak256(0x00, 0x40)\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/ExtensibleFallbackHandler.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./extensible/FallbackHandler.sol\";\nimport \"./extensible/SignatureVerifierMuxer.sol\";\nimport \"./extensible/TokenCallbacks.sol\";\nimport \"./extensible/ERC165Handler.sol\";\n\n/**\n * @title ExtensibleFallbackHandler - A fully extensible fallback handler for Safes\n * @dev Designed to be used with Safe >= 1.3.0.\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\ncontract ExtensibleFallbackHandler is FallbackHandler, SignatureVerifierMuxer, TokenCallbacks, ERC165Handler {\n    /**\n     * Specify specific interfaces (ERC721 + ERC1155) that this contract supports.\n     * @param interfaceId The interface ID to check for support\n     */\n    function _supportsInterface(bytes4 interfaceId) internal pure override returns (bool) {\n        return\n            interfaceId == type(ERC1271).interfaceId ||\n            interfaceId == type(ISignatureVerifierMuxer).interfaceId ||\n            interfaceId == type(ERC165Handler).interfaceId ||\n            interfaceId == type(IFallbackHandler).interfaceId ||\n            interfaceId == type(ERC721TokenReceiver).interfaceId ||\n            interfaceId == type(ERC1155TokenReceiver).interfaceId;\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/libraries/GPv2Order.sol\";\nimport {GPv2Interaction} from \"cowprotocol/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/src/interfaces/ISwapGuard.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\nimport {GPv2Order} from \"cowprotocol/libraries/GPv2Order.sol\";\nimport {IERC165} from \"safe/interfaces/IERC165.sol\";\n\nimport {IConditionalOrder} from \"./IConditionalOrder.sol\";\n\n/**\n * @title SwapGuard Interface - Restrict CoW Protocol settlement for an account using `ComposableCoW`.\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\ninterface ISwapGuard is IERC165 {\n    /**\n     * @notice Verify that the order is allowed to be settled via CoW Protocol.\n     * @param order The order to verify.\n     * @param ctx The context of the order (bytes32(0) if a merkle tree is used, otherwise H(params))\n     * @param params The conditional order parameters (handler, salt, staticInput).\n     * @param offchainInput Any offchain input to verify.\n     * @return True if the order is allowed to be settled via CoW Protocol.\n     */\n    function verify(\n        GPv2Order.Data calldata order,\n        bytes32 ctx,\n        IConditionalOrder.ConditionalOrderParams calldata params,\n        bytes calldata offchainInput\n    ) external view returns (bool);\n}\n"
      },
      "lib/composable-cow/src/interfaces/IValueFactory.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity >=0.8.0 <0.9.0;\n\n/**\n * @title IValueFactory - An interface for on-chain value determination\n * @author mfw78 <mfw78@rndlabs.xyz>\n * @dev Designed to be used with Safe + ExtensibleFallbackHandler + ComposableCoW\n */\ninterface IValueFactory {\n    /**\n     * Return a value at the time of the call\n     * @param data Implementation specific off-chain data\n     * @return value The value at the time of the call\n     */\n    function getValue(bytes calldata data) external view returns (bytes32 value);\n}\n"
      },
      "lib/composable-cow/src/vendored/CoWSettlement.sol": {
        "content": "// SPDX-License-Identifier: MIT\npragma solidity >=0.8.0 <0.9.0;\n\ninterface CoWSettlement {\n    function domainSeparator() external view returns (bytes32);\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} from \"cowprotocol/libraries/GPv2Order.sol\";\n\nimport \"./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 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 returns (address);\n}\n"
      },
      "src/interfaces/IWatchtowerCustomErrors.sol": {
        "content": "// SPDX-License-Identifier: GPL-3.0\npragma solidity ^0.8.24;\n\n/**\n * @title Watchtower Custom Error Interface\n * @author CoW Protocol Developers\n * @dev An interface that collects all custom error message for the watchtower.\n * Different error messages lead to different watchtower behaviors when creating\n * an order.\n * @dev The watchtower is a service that automatically posts orders to the CoW\n * Protocol orderbook at regular intervals.\n */\ncontract IWatchtowerCustomErrors {\n    /**\n     * No order is currently available for trading, but the watchtower should\n     * try again at the specified block.\n     */\n    error PollTryAtBlock(uint256 blockNumber, string message);\n    /**\n     * No order is currently available for trading, but the watchtower should\n     * try again after the timestamp.\n     */\n    error PollTryAtEpoch(uint256 timestamp, string message);\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/FallbackHandler.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./Base.sol\";\n\ninterface IFallbackHandler {\n    function setSafeMethod(bytes4 selector, bytes32 newMethod) external;\n}\n\n/**\n * @title FallbackHandler - A fully extensible fallback handler for Safes\n * @dev This contract provides a fallback handler for Safes that can be extended with custom fallback handlers\n *      for specific methods.\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\nabstract contract FallbackHandler is ExtensibleBase, IFallbackHandler {\n    // --- setters ---\n\n    /**\n     * Setter for custom method handlers\n     * @param selector The `bytes4` selector of the method to set the handler for\n     * @param newMethod A contract that implements the `IFallbackMethod` or `IStaticFallbackMethod` interface\n     */\n    function setSafeMethod(bytes4 selector, bytes32 newMethod) public override onlySelf {\n        _setSafeMethod(Safe(payable(_msgSender())), selector, newMethod);\n    }\n\n    // --- fallback ---\n\n    fallback(bytes calldata) external returns (bytes memory result) {\n        require(msg.data.length >= 24, \"invalid method selector\");\n        (Safe safe, address sender, bool isStatic, address handler) = _getContextAndHandler();\n        require(handler != address(0), \"method handler not set\");\n\n        if (isStatic) {\n            result = IStaticFallbackMethod(handler).handle(safe, sender, 0, msg.data[:msg.data.length - 20]);\n        } else {\n            result = IFallbackMethod(handler).handle(safe, sender, 0, msg.data[:msg.data.length - 20]);\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/SignatureVerifierMuxer.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./Base.sol\";\nimport \"../../interfaces/ISignatureValidator.sol\";\n\ninterface ERC1271 {\n    function isValidSignature(bytes32 hash, bytes calldata signature) external view returns (bytes4 magicValue);\n}\n\n/**\n * @title Safe Signature Verifier Interface\n * @author mfw78 <mfw78@rndlabs.xyz>\n * @notice This interface provides an standard for external contracts that are verifying signatures\n *         for a Safe.\n */\ninterface ISafeSignatureVerifier {\n    /**\n     * @dev If called by `SignatureVerifierMuxer`, the following has already been checked:\n     *      _hash = h(abi.encodePacked(\"\\x19\\x01\", domainSeparator, h(typeHash || encodeData)));\n     * @param safe The Safe that has delegated the signature verification\n     * @param sender The address that originally called the Safe's `isValidSignature` method\n     * @param _hash The EIP-712 hash whose signature will be verified\n     * @param domainSeparator The EIP-712 domainSeparator\n     * @param typeHash The EIP-712 typeHash\n     * @param encodeData The EIP-712 encoded data\n     * @param payload An arbitrary payload that can be used to pass additional data to the verifier\n     * @return magic The magic value that should be returned if the signature is valid (0x1626ba7e)\n     */\n    function isValidSafeSignature(\n        Safe safe,\n        address sender,\n        bytes32 _hash,\n        bytes32 domainSeparator,\n        bytes32 typeHash,\n        bytes calldata encodeData,\n        bytes calldata payload\n    ) external view returns (bytes4 magic);\n}\n\ninterface ISignatureVerifierMuxer {\n    function domainVerifiers(Safe safe, bytes32 domainSeparator) external view returns (ISafeSignatureVerifier);\n\n    function setDomainVerifier(bytes32 domainSeparator, ISafeSignatureVerifier verifier) external;\n}\n\n/**\n * @title ERC-1271 Signature Verifier Multiplexer (Muxer)\n * @author mfw78 <mfw78@rndlabs.xyz>\n * @notice Allows delegating EIP-712 domains to an arbitray `ISafeSignatureVerifier`\n * @dev This multiplexer enforces a strict authorisation per domainSeparator. This is to prevent a malicious\n *     `ISafeSignatureVerifier` from being able to verify signatures for any domainSeparator. This does not prevent\n *      an `ISafeSignatureVerifier` from being able to verify signatures for multiple domainSeparators, however\n *      each domainSeparator requires specific approval by Safe.\n */\nabstract contract SignatureVerifierMuxer is ExtensibleBase, ERC1271, ISignatureVerifierMuxer {\n    // --- constants ---\n    // keccak256(\"SafeMessage(bytes message)\");\n    bytes32 private constant SAFE_MSG_TYPEHASH = 0x60b3cbf8b4a223d68d641b3b6ddf9a298e7f33710cf3d3a9d1146b5a6150fbca;\n    // keccak256(\"safeSignature(bytes32,bytes32,bytes,bytes)\");\n    bytes4 private constant SAFE_SIGNATURE_MAGIC_VALUE = 0x5fd7e97d;\n\n    // --- storage ---\n    mapping(Safe => mapping(bytes32 => ISafeSignatureVerifier)) public override domainVerifiers;\n\n    // --- events ---\n    event AddedDomainVerifier(Safe indexed safe, bytes32 domainSeparator, ISafeSignatureVerifier verifier);\n    event ChangedDomainVerifier(\n        Safe indexed safe,\n        bytes32 domainSeparator,\n        ISafeSignatureVerifier oldVerifier,\n        ISafeSignatureVerifier newVerifier\n    );\n    event RemovedDomainVerifier(Safe indexed safe, bytes32 domainSeparator);\n\n    /**\n     * Setter for the signature muxer\n     * @param domainSeparator The domainSeparator authorised for the `ISafeSignatureVerifier`\n     * @param newVerifier A contract that implements `ISafeSignatureVerifier`\n     */\n    function setDomainVerifier(bytes32 domainSeparator, ISafeSignatureVerifier newVerifier) public override onlySelf {\n        Safe safe = Safe(payable(_msgSender()));\n        ISafeSignatureVerifier oldVerifier = domainVerifiers[safe][domainSeparator];\n        if (address(newVerifier) == address(0) && address(oldVerifier) != address(0)) {\n            delete domainVerifiers[safe][domainSeparator];\n            emit RemovedDomainVerifier(safe, domainSeparator);\n        } else {\n            domainVerifiers[safe][domainSeparator] = newVerifier;\n            if (address(oldVerifier) == address(0)) {\n                emit AddedDomainVerifier(safe, domainSeparator, newVerifier);\n            } else {\n                emit ChangedDomainVerifier(safe, domainSeparator, oldVerifier, newVerifier);\n            }\n        }\n    }\n\n    /**\n     * @notice Implements ERC1271 interface for smart contract EIP-712 signature validation\n     * @dev The signature format is the same as the one used by the Safe contract\n     * @param _hash Hash of the data that is signed\n     * @param signature The signature to be verified\n     * @return magic Standardised ERC1271 return value\n     */\n    function isValidSignature(bytes32 _hash, bytes calldata signature) external view override returns (bytes4 magic) {\n        (Safe safe, address sender) = _getContext();\n\n        // Check if the signature is for an `ISafeSignatureVerifier` and if it is valid for the domain.\n        if (signature.length >= 4) {\n            bytes4 sigSelector;\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                sigSelector := shl(224, shr(224, calldataload(signature.offset)))\n            }\n\n            // Guard against short signatures that would cause abi.decode to revert.\n            if (sigSelector == SAFE_SIGNATURE_MAGIC_VALUE && signature.length >= 68) {\n                // Signature is for an `ISafeSignatureVerifier` - decode the signature.\n                // Layout of the `signature`:\n                // 0x00 - 0x04: selector\n                // 0x04 - 0x36: domainSeparator\n                // 0x36 - 0x68: typeHash\n                // 0x68 - 0x6C: encodeData length\n                // 0x6C - 0x6C + encodeData length: encodeData\n                // 0x6C + encodeData length - 0x6C + encodeData length + 0x20: payload length\n                // 0x6C + encodeData length + 0x20 - end: payload\n                //\n                // Get the domainSeparator from the signature.\n                (bytes32 domainSeparator, bytes32 typeHash) = abi.decode(signature[4:68], (bytes32, bytes32));\n\n                ISafeSignatureVerifier verifier = domainVerifiers[safe][domainSeparator];\n                // Check if there is an `ISafeSignatureVerifier` for the domain.\n                if (address(verifier) != address(0)) {\n                    (, , bytes memory encodeData, bytes memory payload) = abi.decode(signature[4:], (bytes32, bytes32, bytes, bytes));\n\n                    // Check that the signature is valid for the domain.\n                    if (keccak256(EIP712.encodeMessageData(domainSeparator, typeHash, encodeData)) == _hash) {\n                        // Preserving the context, call the Safe's authorised `ISafeSignatureVerifier` to verify.\n                        return verifier.isValidSafeSignature(safe, sender, _hash, domainSeparator, typeHash, encodeData, payload);\n                    }\n                }\n            }\n        }\n\n        // domainVerifier doesn't exist or the signature is invalid for the domain - fall back to the default\n        return defaultIsValidSignature(safe, _hash, signature);\n    }\n\n    /**\n     * Default Safe signature validation (approved hashes / threshold signatures)\n     * @param safe The safe being asked to validate the signature\n     * @param _hash Hash of the data that is signed\n     * @param signature The signature to be verified\n     */\n    function defaultIsValidSignature(Safe safe, bytes32 _hash, bytes memory signature) internal view returns (bytes4 magic) {\n        bytes memory messageData = EIP712.encodeMessageData(\n            safe.domainSeparator(),\n            SAFE_MSG_TYPEHASH,\n            abi.encode(keccak256(abi.encode(_hash)))\n        );\n        bytes32 messageHash = keccak256(messageData);\n        if (signature.length == 0) {\n            // approved hashes\n            require(safe.signedMessages(messageHash) != 0, \"Hash not approved\");\n        } else {\n            // threshold signatures\n            safe.checkSignatures(messageHash, messageData, signature);\n        }\n        magic = ERC1271.isValidSignature.selector;\n    }\n}\n\nlibrary EIP712 {\n    function encodeMessageData(bytes32 domainSeparator, bytes32 typeHash, bytes memory message) internal pure returns (bytes memory) {\n        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator, keccak256(abi.encodePacked(typeHash, message)));\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/TokenCallbacks.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../../interfaces/ERC1155TokenReceiver.sol\";\nimport \"../../interfaces/ERC721TokenReceiver.sol\";\n\nimport \"./Base.sol\";\n\n/**\n * @title TokenCallbacks - ERC1155 and ERC721 token callbacks for Safes\n * @author mfw78 <mfw78@rndlabs.xyz>\n * @notice Refactored from https://github.com/safe-global/safe-contracts/blob/3c3fc80f7f9aef1d39aaae2b53db5f4490051b0d/contracts/handler/TokenCallbackHandler.sol\n */\nabstract contract TokenCallbacks is ExtensibleBase, ERC1155TokenReceiver, ERC721TokenReceiver {\n    /**\n     * @notice Handles ERC1155 Token callback.\n     * return Standardized onERC1155Received return value.\n     */\n    function onERC1155Received(address, address, uint256, uint256, bytes calldata) external pure override returns (bytes4) {\n        // Else return the standard value\n        return 0xf23a6e61;\n    }\n\n    /**\n     * @notice Handles ERC1155 Token batch callback.\n     * return Standardized onERC1155BatchReceived return value.\n     */\n    function onERC1155BatchReceived(\n        address,\n        address,\n        uint256[] calldata,\n        uint256[] calldata,\n        bytes calldata\n    ) external pure override returns (bytes4) {\n        // Else return the standard value\n        return 0xbc197c81;\n    }\n\n    /**\n     * @notice Handles ERC721 Token callback.\n     *  return Standardized onERC721Received return value.\n     */\n    function onERC721Received(address, address, uint256, bytes calldata) external pure override returns (bytes4) {\n        // Else return the standard value\n        return 0x150b7a02;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/ERC165Handler.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport {IERC165} from \"../../interfaces/IERC165.sol\";\n\nimport \"./Base.sol\";\n\ninterface IERC165Handler {\n    function safeInterfaces(Safe safe, bytes4 interfaceId) external view returns (bool);\n\n    function setSupportedInterface(bytes4 interfaceId, bool supported) external;\n\n    function addSupportedInterfaceBatch(bytes4 interfaceId, bytes32[] calldata handlerWithSelectors) external;\n\n    function removeSupportedInterfaceBatch(bytes4 interfaceId, bytes4[] calldata selectors) external;\n}\n\nabstract contract ERC165Handler is ExtensibleBase, IERC165Handler {\n    // --- events ---\n\n    event AddedInterface(Safe indexed safe, bytes4 interfaceId);\n    event RemovedInterface(Safe indexed safe, bytes4 interfaceId);\n\n    // --- storage ---\n\n    mapping(Safe => mapping(bytes4 => bool)) public override safeInterfaces;\n\n    // --- setters ---\n\n    /**\n     * Setter to indicate if an interface is supported (and thus reported by ERC165 supportsInterface)\n     * @param interfaceId The interface id whose support is to be set\n     * @param supported True if the interface is supported, false otherwise\n     */\n    function setSupportedInterface(bytes4 interfaceId, bool supported) public override onlySelf {\n        Safe safe = Safe(payable(_manager()));\n        // invalid interface id per ERC165 spec\n        require(interfaceId != 0xffffffff, \"invalid interface id\");\n        bool current = safeInterfaces[safe][interfaceId];\n        if (supported && !current) {\n            safeInterfaces[safe][interfaceId] = true;\n            emit AddedInterface(safe, interfaceId);\n        } else if (!supported && current) {\n            delete safeInterfaces[safe][interfaceId];\n            emit RemovedInterface(safe, interfaceId);\n        }\n    }\n\n    /**\n     * Batch add selectors for an interface.\n     * @param _interfaceId The interface id to set\n     * @param handlerWithSelectors The handlers encoded with the 4-byte selectors of the methods\n     */\n    function addSupportedInterfaceBatch(bytes4 _interfaceId, bytes32[] calldata handlerWithSelectors) external override onlySelf {\n        Safe safe = Safe(payable(_msgSender()));\n        bytes4 interfaceId;\n        for (uint256 i = 0; i < handlerWithSelectors.length; i++) {\n            (bool isStatic, bytes4 selector, address handlerAddress) = MarshalLib.decodeWithSelector(handlerWithSelectors[i]);\n            _setSafeMethod(safe, selector, MarshalLib.encode(isStatic, handlerAddress));\n            if (i > 0) {\n                interfaceId ^= selector;\n            } else {\n                interfaceId = selector;\n            }\n        }\n\n        require(interfaceId == _interfaceId, \"interface id mismatch\");\n        setSupportedInterface(_interfaceId, true);\n    }\n\n    /**\n     * Batch remove selectors for an interface.\n     * @param _interfaceId the interface id to remove\n     * @param selectors The selectors of the methods to remove\n     */\n    function removeSupportedInterfaceBatch(bytes4 _interfaceId, bytes4[] calldata selectors) external override onlySelf {\n        Safe safe = Safe(payable(_msgSender()));\n        bytes4 interfaceId;\n        for (uint256 i = 0; i < selectors.length; i++) {\n            _setSafeMethod(safe, selectors[i], bytes32(0));\n            if (i > 0) {\n                interfaceId ^= selectors[i];\n            } else {\n                interfaceId = selectors[i];\n            }\n        }\n\n        require(interfaceId == _interfaceId, \"interface id mismatch\");\n        setSupportedInterface(_interfaceId, false);\n    }\n\n    /**\n     * @notice Implements ERC165 interface detection for the supported interfaces\n     * @dev Inheriting contracts should override `_supportsInterface` to add support for additional interfaces\n     * @param interfaceId The ERC165 interface id to check\n     * @return True if the interface is supported\n     */\n    function supportsInterface(bytes4 interfaceId) external view returns (bool) {\n        return\n            interfaceId == type(IERC165).interfaceId ||\n            interfaceId == type(IERC165Handler).interfaceId ||\n            _supportsInterface(interfaceId) ||\n            safeInterfaces[Safe(payable(_manager()))][interfaceId];\n    }\n\n    // --- internal ---\n\n    /**\n     * A stub function to be overridden by inheriting contracts to add support for additional interfaces\n     * @param interfaceId The interface id to check support for\n     * @return True if the interface is supported\n     */\n    function _supportsInterface(bytes4 interfaceId) internal view virtual returns (bool);\n}\n"
      },
      "lib/composable-cow/lib/cowprotocol/src/contracts/libraries/GPv2Order.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\npragma solidity >=0.8.0 <0.9.0;\n\nimport \"@openzeppelin/contracts/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(Data memory order, address owner)\n        internal\n        pure\n        returns (address receiver)\n    {\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(Data memory order, bytes32 domainSeparator)\n        internal\n        pure\n        returns (bytes32 orderDigest)\n    {\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(bytes calldata orderUid)\n        internal\n        pure\n        returns (\n            bytes32 orderDigest,\n            address owner,\n            uint32 validTo\n        )\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/lib/cowprotocol/src/contracts/libraries/GPv2Interaction.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-or-later\npragma solidity >=0.8.0 <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(Data calldata interaction)\n        internal\n        pure\n        returns (bytes4 result)\n    {\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"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/Base.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport {Safe} from \"../../Safe.sol\";\nimport {HandlerContext} from \"../HandlerContext.sol\";\nimport {MarshalLib} from \"./MarshalLib.sol\";\n\ninterface IFallbackMethod {\n    function handle(Safe safe, address sender, uint256 value, bytes calldata data) external returns (bytes memory result);\n}\n\ninterface IStaticFallbackMethod {\n    function handle(Safe safe, address sender, uint256 value, bytes calldata data) external view returns (bytes memory result);\n}\n\n/**\n * @title Base contract for Extensible Fallback Handlers\n * @dev This contract provides the base for storage and modifiers for extensible fallback handlers\n * @author mfw78 <mfw78@rndlabs.xyz>\n */\nabstract contract ExtensibleBase is HandlerContext {\n    // --- events ---\n    event AddedSafeMethod(Safe indexed safe, bytes4 selector, bytes32 method);\n    event ChangedSafeMethod(Safe indexed safe, bytes4 selector, bytes32 oldMethod, bytes32 newMethod);\n    event RemovedSafeMethod(Safe indexed safe, bytes4 selector);\n\n    // --- storage ---\n\n    // A mapping of Safe => selector => method\n    // The method is a bytes32 that is encoded as follows:\n    // - The first byte is 0x00 if the method is static and 0x01 if the method is not static\n    // - The last 20 bytes are the address of the handler contract\n    // The method is encoded / decoded using the MarshalLib\n    mapping(Safe => mapping(bytes4 => bytes32)) public safeMethods;\n\n    // --- modifiers ---\n    modifier onlySelf() {\n        // Use the `HandlerContext._msgSender()` to get the caller of the fallback function\n        // Use the `HandlerContext._manager()` to get the manager, which should be the Safe\n        // Require that the caller is the Safe itself\n        require(_msgSender() == _manager(), \"only safe can call this method\");\n        _;\n    }\n\n    // --- internal ---\n\n    function _setSafeMethod(Safe safe, bytes4 selector, bytes32 newMethod) internal {\n        (, address newHandler) = MarshalLib.decode(newMethod);\n        bytes32 oldMethod = safeMethods[safe][selector];\n        (, address oldHandler) = MarshalLib.decode(oldMethod);\n\n        if (address(newHandler) == address(0) && address(oldHandler) != address(0)) {\n            delete safeMethods[safe][selector];\n            emit RemovedSafeMethod(safe, selector);\n        } else {\n            safeMethods[safe][selector] = newMethod;\n            if (address(oldHandler) == address(0)) {\n                emit AddedSafeMethod(safe, selector, newMethod);\n            } else {\n                emit ChangedSafeMethod(safe, selector, oldMethod, newMethod);\n            }\n        }\n    }\n\n    /**\n     * Dry code to get the Safe and the original `msg.sender` from the FallbackManager\n     * @return safe The safe whose FallbackManager is making this call\n     * @return sender The original `msg.sender` (as received by the FallbackManager)\n     */\n    function _getContext() internal view returns (Safe safe, address sender) {\n        safe = Safe(payable(_manager()));\n        sender = _msgSender();\n    }\n\n    /**\n     * Get the context and the method handler applicable to the current call\n     * @return safe The safe whose FallbackManager is making this call\n     * @return sender The original `msg.sender` (as received by the FallbackManager)\n     * @return isStatic Whether the method is static (`view`) or not\n     * @return handler the address of the handler contract\n     */\n    function _getContextAndHandler() internal view returns (Safe safe, address sender, bool isStatic, address handler) {\n        (safe, sender) = _getContext();\n        (isStatic, handler) = MarshalLib.decode(safeMethods[safe][msg.sig]);\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/interfaces/ISignatureValidator.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\ncontract ISignatureValidatorConstants {\n    // bytes4(keccak256(\"isValidSignature(bytes,bytes)\")\n    bytes4 internal constant EIP1271_MAGIC_VALUE = 0x20c13b0b;\n}\n\nabstract contract ISignatureValidator is ISignatureValidatorConstants {\n    /**\n     * @notice Legacy EIP1271 method to validate a signature.\n     * @param _data Arbitrary length data signed on the behalf of address(this).\n     * @param _signature Signature byte array associated with _data.\n     *\n     * MUST return the bytes4 magic value 0x20c13b0b when function passes.\n     * MUST NOT modify state (using STATICCALL for solc < 0.5, view modifier for solc > 0.5)\n     * MUST allow external calls\n     */\n    function isValidSignature(bytes memory _data, bytes memory _signature) public view virtual returns (bytes4);\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/interfaces/ERC1155TokenReceiver.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n// Note: The ERC-165 identifier for this interface is 0x4e2312e0.\ninterface ERC1155TokenReceiver {\n    /**\n     * @notice Handle the receipt of a single ERC1155 token type.\n     * @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeTransferFrom` after the balance has been updated.\n     *      This function MUST return `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))` (i.e. 0xf23a6e61) if it accepts the transfer.\n     *      This function MUST revert if it rejects the transfer.\n     *      Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.\n     * @param _operator  The address which initiated the transfer (i.e. msg.sender).\n     * @param _from      The address which previously owned the token.\n     * @param _id        The ID of the token being transferred.\n     * @param _value     The amount of tokens being transferred.\n     * @param _data      Additional data with no specified format.\n     * @return           `bytes4(keccak256(\"onERC1155Received(address,address,uint256,uint256,bytes)\"))`.\n     */\n    function onERC1155Received(\n        address _operator,\n        address _from,\n        uint256 _id,\n        uint256 _value,\n        bytes calldata _data\n    ) external returns (bytes4);\n\n    /**\n     * @notice Handle the receipt of multiple ERC1155 token types.\n     * @dev An ERC1155-compliant smart contract MUST call this function on the token recipient contract, at the end of a `safeBatchTransferFrom` after the balances have been updated.\n     *      This function MUST return `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))` (i.e. 0xbc197c81) if it accepts the transfer(s).\n     *      This function MUST revert if it rejects the transfer(s).\n     *      Return of any other value than the prescribed keccak256 generated value MUST result in the transaction being reverted by the caller.\n     * @param _operator  The address which initiated the batch transfer (i.e. msg.sender).\n     * @param _from      The address which previously owned the token.\n     * @param _ids       An array containing ids of each token being transferred (order and length must match _values array).\n     * @param _values    An array containing amounts of each token being transferred (order and length must match _ids array).\n     * @param _data      Additional data with no specified format.\n     * @return           `bytes4(keccak256(\"onERC1155BatchReceived(address,address,uint256[],uint256[],bytes)\"))`.\n     */\n    function onERC1155BatchReceived(\n        address _operator,\n        address _from,\n        uint256[] calldata _ids,\n        uint256[] calldata _values,\n        bytes calldata _data\n    ) external returns (bytes4);\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/interfaces/ERC721TokenReceiver.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/// @dev Note: the ERC-165 identifier for this interface is 0x150b7a02.\ninterface ERC721TokenReceiver {\n    /**\n     * @notice Handle the receipt of an NFT\n     * @dev The ERC721 smart contract calls this function on the recipient\n     *  after a `transfer`. This function MAY throw to revert and reject the\n     *  transfer. Return of other than the magic value MUST result in the\n     *  transaction being reverted.\n     *  Note: the contract address is always the message sender.\n     * @param _operator The address which called `safeTransferFrom` function.\n     * @param _from The address which previously owned the token.\n     * @param _tokenId The NFT identifier which is being transferred.\n     * @param _data Additional data with no specified format.\n     * @return `bytes4(keccak256(\"onERC721Received(address,address,uint256,bytes)\"))`.\n     *  unless throwing\n     */\n    function onERC721Received(address _operator, address _from, uint256 _tokenId, bytes calldata _data) external returns (bytes4);\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/Safe.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"./base/ModuleManager.sol\";\nimport \"./base/OwnerManager.sol\";\nimport \"./base/FallbackManager.sol\";\nimport \"./base/GuardManager.sol\";\nimport \"./common/NativeCurrencyPaymentFallback.sol\";\nimport \"./common/Singleton.sol\";\nimport \"./common/SignatureDecoder.sol\";\nimport \"./common/SecuredTokenTransfer.sol\";\nimport \"./common/StorageAccessible.sol\";\nimport \"./interfaces/ISignatureValidator.sol\";\nimport \"./external/SafeMath.sol\";\n\n/**\n * @title Safe - A multisignature wallet with support for confirmations using signed messages based on EIP-712.\n * @dev Most important concepts:\n *      - Threshold: Number of required confirmations for a Safe transaction.\n *      - Owners: List of addresses that control the Safe. They are the only ones that can add/remove owners, change the threshold and\n *        approve transactions. Managed in `OwnerManager`.\n *      - Transaction Hash: Hash of a transaction is calculated using the EIP-712 typed structured data hashing scheme.\n *      - Nonce: Each transaction should have a different nonce to prevent replay attacks.\n *      - Signature: A valid signature of an owner of the Safe for a transaction hash.\n *      - Guard: Guard is a contract that can execute pre- and post- transaction checks. Managed in `GuardManager`.\n *      - Modules: Modules are contracts that can be used to extend the write functionality of a Safe. Managed in `ModuleManager`.\n *      - Fallback: Fallback handler is a contract that can provide additional read-only functional for Safe. Managed in `FallbackManager`.\n *      Note: This version of the implementation contract doesn't emit events for the sake of gas efficiency and therefore requires a tracing node for indexing/\n *      For the events-based implementation see `SafeL2.sol`.\n * @author Stefan George - @Georgi87\n * @author Richard Meissner - @rmeissner\n */\ncontract Safe is\n    Singleton,\n    NativeCurrencyPaymentFallback,\n    ModuleManager,\n    OwnerManager,\n    SignatureDecoder,\n    SecuredTokenTransfer,\n    ISignatureValidatorConstants,\n    FallbackManager,\n    StorageAccessible,\n    GuardManager\n{\n    using SafeMath for uint256;\n\n    string public constant VERSION = \"1.4.1\";\n\n    // keccak256(\n    //     \"EIP712Domain(uint256 chainId,address verifyingContract)\"\n    // );\n    bytes32 private constant DOMAIN_SEPARATOR_TYPEHASH = 0x47e79534a245952e8b16893a336b85a3d9ea9fa8c573f3d803afb92a79469218;\n\n    // keccak256(\n    //     \"SafeTx(address to,uint256 value,bytes data,uint8 operation,uint256 safeTxGas,uint256 baseGas,uint256 gasPrice,address gasToken,address refundReceiver,uint256 nonce)\"\n    // );\n    bytes32 private constant SAFE_TX_TYPEHASH = 0xbb8310d486368db6bd6f849402fdd73ad53d316b5a4b2644ad6efe0f941286d8;\n\n    event SafeSetup(address indexed initiator, address[] owners, uint256 threshold, address initializer, address fallbackHandler);\n    event ApproveHash(bytes32 indexed approvedHash, address indexed owner);\n    event SignMsg(bytes32 indexed msgHash);\n    event ExecutionFailure(bytes32 indexed txHash, uint256 payment);\n    event ExecutionSuccess(bytes32 indexed txHash, uint256 payment);\n\n    uint256 public nonce;\n    bytes32 private _deprecatedDomainSeparator;\n    // Mapping to keep track of all message hashes that have been approved by ALL REQUIRED owners\n    mapping(bytes32 => uint256) public signedMessages;\n    // Mapping to keep track of all hashes (message or transaction) that have been approved by ANY owners\n    mapping(address => mapping(bytes32 => uint256)) public approvedHashes;\n\n    // This constructor ensures that this contract can only be used as a singleton for Proxy contracts\n    constructor() {\n        /**\n         * By setting the threshold it is not possible to call setup anymore,\n         * so we create a Safe with 0 owners and threshold 1.\n         * This is an unusable Safe, perfect for the singleton\n         */\n        threshold = 1;\n    }\n\n    /**\n     * @notice Sets an initial storage of the Safe contract.\n     * @dev This method can only be called once.\n     *      If a proxy was created without setting up, anyone can call setup and claim the proxy.\n     * @param _owners List of Safe owners.\n     * @param _threshold Number of required confirmations for a Safe transaction.\n     * @param to Contract address for optional delegate call.\n     * @param data Data payload for optional delegate call.\n     * @param fallbackHandler Handler for fallback calls to this contract\n     * @param paymentToken Token that should be used for the payment (0 is ETH)\n     * @param payment Value that should be paid\n     * @param paymentReceiver Address that should receive the payment (or 0 if tx.origin)\n     */\n    function setup(\n        address[] calldata _owners,\n        uint256 _threshold,\n        address to,\n        bytes calldata data,\n        address fallbackHandler,\n        address paymentToken,\n        uint256 payment,\n        address payable paymentReceiver\n    ) external {\n        // setupOwners checks if the Threshold is already set, therefore preventing that this method is called twice\n        setupOwners(_owners, _threshold);\n        if (fallbackHandler != address(0)) internalSetFallbackHandler(fallbackHandler);\n        // As setupOwners can only be called if the contract has not been initialized we don't need a check for setupModules\n        setupModules(to, data);\n\n        if (payment > 0) {\n            // To avoid running into issues with EIP-170 we reuse the handlePayment function (to avoid adjusting code of that has been verified we do not adjust the method itself)\n            // baseGas = 0, gasPrice = 1 and gas = payment => amount = (payment + 0) * 1 = payment\n            handlePayment(payment, 0, 1, paymentToken, paymentReceiver);\n        }\n        emit SafeSetup(msg.sender, _owners, _threshold, to, fallbackHandler);\n    }\n\n    /** @notice Executes a `operation` {0: Call, 1: DelegateCall}} transaction to `to` with `value` (Native Currency)\n     *          and pays `gasPrice` * `gasLimit` in `gasToken` token to `refundReceiver`.\n     * @dev The fees are always transferred, even if the user transaction fails.\n     *      This method doesn't perform any sanity check of the transaction, such as:\n     *      - if the contract at `to` address has code or not\n     *      - if the `gasToken` is a contract or not\n     *      It is the responsibility of the caller to perform such checks.\n     * @param to Destination address of Safe transaction.\n     * @param value Ether value of Safe transaction.\n     * @param data Data payload of Safe transaction.\n     * @param operation Operation type of Safe transaction.\n     * @param safeTxGas Gas that should be used for the Safe transaction.\n     * @param baseGas Gas costs that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n     * @param gasPrice Gas price that should be used for the payment calculation.\n     * @param gasToken Token address (or 0 if ETH) that is used for the payment.\n     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     * @return success Boolean indicating transaction's success.\n     */\n    function execTransaction(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 safeTxGas,\n        uint256 baseGas,\n        uint256 gasPrice,\n        address gasToken,\n        address payable refundReceiver,\n        bytes memory signatures\n    ) public payable virtual returns (bool success) {\n        bytes32 txHash;\n        // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n        {\n            bytes memory txHashData = encodeTransactionData(\n                // Transaction info\n                to,\n                value,\n                data,\n                operation,\n                safeTxGas,\n                // Payment info\n                baseGas,\n                gasPrice,\n                gasToken,\n                refundReceiver,\n                // Signature info\n                nonce\n            );\n            // Increase nonce and execute transaction.\n            nonce++;\n            txHash = keccak256(txHashData);\n            checkSignatures(txHash, txHashData, signatures);\n        }\n        address guard = getGuard();\n        {\n            if (guard != address(0)) {\n                Guard(guard).checkTransaction(\n                    // Transaction info\n                    to,\n                    value,\n                    data,\n                    operation,\n                    safeTxGas,\n                    // Payment info\n                    baseGas,\n                    gasPrice,\n                    gasToken,\n                    refundReceiver,\n                    // Signature info\n                    signatures,\n                    msg.sender\n                );\n            }\n        }\n        // We require some gas to emit the events (at least 2500) after the execution and some to perform code until the execution (500)\n        // We also include the 1/64 in the check that is not send along with a call to counteract potential shortings because of EIP-150\n        require(gasleft() >= ((safeTxGas * 64) / 63).max(safeTxGas + 2500) + 500, \"GS010\");\n        // Use scope here to limit variable lifetime and prevent `stack too deep` errors\n        {\n            uint256 gasUsed = gasleft();\n            // If the gasPrice is 0 we assume that nearly all available gas can be used (it is always more than safeTxGas)\n            // We only substract 2500 (compared to the 3000 before) to ensure that the amount passed is still higher than safeTxGas\n            success = execute(to, value, data, operation, gasPrice == 0 ? (gasleft() - 2500) : safeTxGas);\n            gasUsed = gasUsed.sub(gasleft());\n            // If no safeTxGas and no gasPrice was set (e.g. both are 0), then the internal tx is required to be successful\n            // This makes it possible to use `estimateGas` without issues, as it searches for the minimum gas where the tx doesn't revert\n            require(success || safeTxGas != 0 || gasPrice != 0, \"GS013\");\n            // We transfer the calculated tx costs to the tx.origin to avoid sending it to intermediate contracts that have made calls\n            uint256 payment = 0;\n            if (gasPrice > 0) {\n                payment = handlePayment(gasUsed, baseGas, gasPrice, gasToken, refundReceiver);\n            }\n            if (success) emit ExecutionSuccess(txHash, payment);\n            else emit ExecutionFailure(txHash, payment);\n        }\n        {\n            if (guard != address(0)) {\n                Guard(guard).checkAfterExecution(txHash, success);\n            }\n        }\n    }\n\n    /**\n     * @notice Handles the payment for a Safe transaction.\n     * @param gasUsed Gas used by the Safe transaction.\n     * @param baseGas Gas costs that are independent of the transaction execution (e.g. base transaction fee, signature check, payment of the refund).\n     * @param gasPrice Gas price that should be used for the payment calculation.\n     * @param gasToken Token address (or 0 if ETH) that is used for the payment.\n     * @return payment The amount of payment made in the specified token.\n     */\n    function handlePayment(\n        uint256 gasUsed,\n        uint256 baseGas,\n        uint256 gasPrice,\n        address gasToken,\n        address payable refundReceiver\n    ) private returns (uint256 payment) {\n        // solhint-disable-next-line avoid-tx-origin\n        address payable receiver = refundReceiver == address(0) ? payable(tx.origin) : refundReceiver;\n        if (gasToken == address(0)) {\n            // For ETH we will only adjust the gas price to not be higher than the actual used gas price\n            payment = gasUsed.add(baseGas).mul(gasPrice < tx.gasprice ? gasPrice : tx.gasprice);\n            require(receiver.send(payment), \"GS011\");\n        } else {\n            payment = gasUsed.add(baseGas).mul(gasPrice);\n            require(transferToken(gasToken, receiver, payment), \"GS012\");\n        }\n    }\n\n    /**\n     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.\n     * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n     * @param data That should be signed (this is passed to an external validator contract)\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     */\n    function checkSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures) public view {\n        // Load threshold to avoid multiple storage loads\n        uint256 _threshold = threshold;\n        // Check that a threshold is set\n        require(_threshold > 0, \"GS001\");\n        checkNSignatures(dataHash, data, signatures, _threshold);\n    }\n\n    /**\n     * @notice Checks whether the signature provided is valid for the provided data and hash. Reverts otherwise.\n     * @dev Since the EIP-1271 does an external call, be mindful of reentrancy attacks.\n     * @param dataHash Hash of the data (could be either a message hash or transaction hash)\n     * @param data That should be signed (this is passed to an external validator contract)\n     * @param signatures Signature data that should be verified.\n     *                   Can be packed ECDSA signature ({bytes32 r}{bytes32 s}{uint8 v}), contract signature (EIP-1271) or approved hash.\n     * @param requiredSignatures Amount of required valid signatures.\n     */\n    function checkNSignatures(bytes32 dataHash, bytes memory data, bytes memory signatures, uint256 requiredSignatures) public view {\n        // Check that the provided signature data is not too short\n        require(signatures.length >= requiredSignatures.mul(65), \"GS020\");\n        // There cannot be an owner with address 0.\n        address lastOwner = address(0);\n        address currentOwner;\n        uint8 v;\n        bytes32 r;\n        bytes32 s;\n        uint256 i;\n        for (i = 0; i < requiredSignatures; i++) {\n            (v, r, s) = signatureSplit(signatures, i);\n            if (v == 0) {\n                require(keccak256(data) == dataHash, \"GS027\");\n                // If v is 0 then it is a contract signature\n                // When handling contract signatures the address of the contract is encoded into r\n                currentOwner = address(uint160(uint256(r)));\n\n                // Check that signature data pointer (s) is not pointing inside the static part of the signatures bytes\n                // This check is not completely accurate, since it is possible that more signatures than the threshold are send.\n                // Here we only check that the pointer is not pointing inside the part that is being processed\n                require(uint256(s) >= requiredSignatures.mul(65), \"GS021\");\n\n                // Check that signature data pointer (s) is in bounds (points to the length of data -> 32 bytes)\n                require(uint256(s).add(32) <= signatures.length, \"GS022\");\n\n                // Check if the contract signature is in bounds: start of data is s + 32 and end is start + signature length\n                uint256 contractSignatureLen;\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    contractSignatureLen := mload(add(add(signatures, s), 0x20))\n                }\n                require(uint256(s).add(32).add(contractSignatureLen) <= signatures.length, \"GS023\");\n\n                // Check signature\n                bytes memory contractSignature;\n                // solhint-disable-next-line no-inline-assembly\n                assembly {\n                    // The signature data for contract signatures is appended to the concatenated signatures and the offset is stored in s\n                    contractSignature := add(add(signatures, s), 0x20)\n                }\n                require(ISignatureValidator(currentOwner).isValidSignature(data, contractSignature) == EIP1271_MAGIC_VALUE, \"GS024\");\n            } else if (v == 1) {\n                // If v is 1 then it is an approved hash\n                // When handling approved hashes the address of the approver is encoded into r\n                currentOwner = address(uint160(uint256(r)));\n                // Hashes are automatically approved by the sender of the message or when they have been pre-approved via a separate transaction\n                require(msg.sender == currentOwner || approvedHashes[currentOwner][dataHash] != 0, \"GS025\");\n            } else if (v > 30) {\n                // If v > 30 then default va (27,28) has been adjusted for eth_sign flow\n                // To support eth_sign and similar we adjust v and hash the messageHash with the Ethereum message prefix before applying ecrecover\n                currentOwner = ecrecover(keccak256(abi.encodePacked(\"\\x19Ethereum Signed Message:\\n32\", dataHash)), v - 4, r, s);\n            } else {\n                // Default is the ecrecover flow with the provided data hash\n                // Use ecrecover with the messageHash for EOA signatures\n                currentOwner = ecrecover(dataHash, v, r, s);\n            }\n            require(currentOwner > lastOwner && owners[currentOwner] != address(0) && currentOwner != SENTINEL_OWNERS, \"GS026\");\n            lastOwner = currentOwner;\n        }\n    }\n\n    /**\n     * @notice Marks hash `hashToApprove` as approved.\n     * @dev This can be used with a pre-approved hash transaction signature.\n     *      IMPORTANT: The approved hash stays approved forever. There's no revocation mechanism, so it behaves similarly to ECDSA signatures\n     * @param hashToApprove The hash to mark as approved for signatures that are verified by this contract.\n     */\n    function approveHash(bytes32 hashToApprove) external {\n        require(owners[msg.sender] != address(0), \"GS030\");\n        approvedHashes[msg.sender][hashToApprove] = 1;\n        emit ApproveHash(hashToApprove, msg.sender);\n    }\n\n    /**\n     * @notice Returns the ID of the chain the contract is currently deployed on.\n     * @return The ID of the current chain as a uint256.\n     */\n    function getChainId() public view returns (uint256) {\n        uint256 id;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            id := chainid()\n        }\n        return id;\n    }\n\n    /**\n     * @dev Returns the domain separator for this contract, as defined in the EIP-712 standard.\n     * @return bytes32 The domain separator hash.\n     */\n    function domainSeparator() public view returns (bytes32) {\n        return keccak256(abi.encode(DOMAIN_SEPARATOR_TYPEHASH, getChainId(), this));\n    }\n\n    /**\n     * @notice Returns the pre-image of the transaction hash (see getTransactionHash).\n     * @param to Destination address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @param safeTxGas Gas that should be used for the safe transaction.\n     * @param baseGas Gas costs for that are independent of the transaction execution(e.g. base transaction fee, signature check, payment of the refund)\n     * @param gasPrice Maximum gas price that should be used for this transaction.\n     * @param gasToken Token address (or 0 if ETH) that is used for the payment.\n     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n     * @param _nonce Transaction nonce.\n     * @return Transaction hash bytes.\n     */\n    function encodeTransactionData(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 safeTxGas,\n        uint256 baseGas,\n        uint256 gasPrice,\n        address gasToken,\n        address refundReceiver,\n        uint256 _nonce\n    ) public view returns (bytes memory) {\n        bytes32 safeTxHash = keccak256(\n            abi.encode(\n                SAFE_TX_TYPEHASH,\n                to,\n                value,\n                keccak256(data),\n                operation,\n                safeTxGas,\n                baseGas,\n                gasPrice,\n                gasToken,\n                refundReceiver,\n                _nonce\n            )\n        );\n        return abi.encodePacked(bytes1(0x19), bytes1(0x01), domainSeparator(), safeTxHash);\n    }\n\n    /**\n     * @notice Returns transaction hash to be signed by owners.\n     * @param to Destination address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @param safeTxGas Fas that should be used for the safe transaction.\n     * @param baseGas Gas costs for data used to trigger the safe transaction.\n     * @param gasPrice Maximum gas price that should be used for this transaction.\n     * @param gasToken Token address (or 0 if ETH) that is used for the payment.\n     * @param refundReceiver Address of receiver of gas payment (or 0 if tx.origin).\n     * @param _nonce Transaction nonce.\n     * @return Transaction hash.\n     */\n    function getTransactionHash(\n        address to,\n        uint256 value,\n        bytes calldata data,\n        Enum.Operation operation,\n        uint256 safeTxGas,\n        uint256 baseGas,\n        uint256 gasPrice,\n        address gasToken,\n        address refundReceiver,\n        uint256 _nonce\n    ) public view returns (bytes32) {\n        return keccak256(encodeTransactionData(to, value, data, operation, safeTxGas, baseGas, gasPrice, gasToken, refundReceiver, _nonce));\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/HandlerContext.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Handler Context - Allows the fallback handler to extract addition context from the calldata\n * @dev The fallback manager appends the following context to the calldata:\n *      1. Fallback manager caller address (non-padded)\n * based on https://github.com/OpenZeppelin/openzeppelin-contracts/blob/f8cc8b844a9f92f63dc55aa581f7d643a1bc5ac1/contracts/metatx/ERC2771Context.sol\n * @author Richard Meissner - @rmeissner\n */\nabstract contract HandlerContext {\n    /**\n     * @notice Allows fetching the original caller address.\n     * @dev This is only reliable in combination with a FallbackManager that supports this (e.g. Safe contract >=1.3.0).\n     *      When using this functionality make sure that the linked _manager (aka msg.sender) supports this.\n     *      This function does not rely on a trusted forwarder. Use the returned value only to\n     *      check information against the calling manager.\n     * @return sender Original caller address.\n     */\n    function _msgSender() internal pure returns (address sender) {\n        require(msg.data.length >= 20, \"Invalid calldata length\");\n        // The assembly code is more direct than the Solidity version using `abi.decode`.\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sender := shr(96, calldataload(sub(calldatasize(), 20)))\n        }\n    }\n\n    /**\n     * @notice Returns the FallbackManager address\n     * @return Fallback manager address\n     */\n    function _manager() internal view returns (address) {\n        return msg.sender;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/handler/extensible/MarshalLib.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nlibrary MarshalLib {\n    /**\n     * Encode a method handler into a `bytes32` value\n     * @dev The first byte of the `bytes32` value is set to 0x01 if the method is not static (`view`)\n     * @dev The last 20 bytes of the `bytes32` value are set to the address of the handler contract\n     * @param isStatic Whether the method is static (`view`) or not\n     * @param handler The address of the handler contract implementing the `IFallbackMethod` or `IStaticFallbackMethod` interface\n     */\n    function encode(bool isStatic, address handler) internal pure returns (bytes32 data) {\n        data = bytes32(uint256(uint160(handler)) | (isStatic ? 0 : (1 << 248)));\n    }\n\n    function encodeWithSelector(bool isStatic, bytes4 selector, address handler) internal pure returns (bytes32 data) {\n        data = bytes32(uint256(uint160(handler)) | (isStatic ? 0 : (1 << 248)) | (uint256(uint32(selector)) << 216));\n    }\n\n    /**\n     * Given a `bytes32` value, decode it into a method handler and return it\n     * @param data The packed data to decode\n     * @return isStatic Whether the method is static (`view`) or not\n     * @return handler The address of the handler contract implementing the `IFallbackMethod` or `IStaticFallbackMethod` interface\n     */\n    function decode(bytes32 data) internal pure returns (bool isStatic, address handler) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // set isStatic to true if the left-most byte of the data is not 0x00\n            isStatic := iszero(shr(248, data))\n            handler := shr(96, shl(96, data))\n        }\n    }\n\n    function decodeWithSelector(bytes32 data) internal pure returns (bool isStatic, bytes4 selector, address handler) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // set isStatic to true if the left-most byte of the data is not 0x00\n            isStatic := iszero(shr(248, data))\n            handler := shr(96, shl(96, data))\n            selector := shl(168, shr(160, data))\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/base/ModuleManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"./Executor.sol\";\n\n/**\n * @title Module Manager - A contract managing Safe modules\n * @notice Modules are extensions with unlimited access to a Safe that can be added to a Safe by its owners.\n           ⚠️ WARNING: Modules are a security risk since they can execute arbitrary transactions, \n           so only trusted and audited modules should be added to a Safe. A malicious module can\n           completely takeover a Safe.\n * @author Stefan George - @Georgi87\n * @author Richard Meissner - @rmeissner\n */\nabstract contract ModuleManager is SelfAuthorized, Executor {\n    event EnabledModule(address indexed module);\n    event DisabledModule(address indexed module);\n    event ExecutionFromModuleSuccess(address indexed module);\n    event ExecutionFromModuleFailure(address indexed module);\n\n    address internal constant SENTINEL_MODULES = address(0x1);\n\n    mapping(address => address) internal modules;\n\n    /**\n     * @notice Setup function sets the initial storage of the contract.\n     *         Optionally executes a delegate call to another contract to setup the modules.\n     * @param to Optional destination address of call to execute.\n     * @param data Optional data of call to execute.\n     */\n    function setupModules(address to, bytes memory data) internal {\n        require(modules[SENTINEL_MODULES] == address(0), \"GS100\");\n        modules[SENTINEL_MODULES] = SENTINEL_MODULES;\n        if (to != address(0)) {\n            require(isContract(to), \"GS002\");\n            // Setup has to complete successfully or transaction fails.\n            require(execute(to, 0, data, Enum.Operation.DelegateCall, type(uint256).max), \"GS000\");\n        }\n    }\n\n    /**\n     * @notice Enables the module `module` for the Safe.\n     * @dev This can only be done via a Safe transaction.\n     * @param module Module to be whitelisted.\n     */\n    function enableModule(address module) public authorized {\n        // Module address cannot be null or sentinel.\n        require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n        // Module cannot be added twice.\n        require(modules[module] == address(0), \"GS102\");\n        modules[module] = modules[SENTINEL_MODULES];\n        modules[SENTINEL_MODULES] = module;\n        emit EnabledModule(module);\n    }\n\n    /**\n     * @notice Disables the module `module` for the Safe.\n     * @dev This can only be done via a Safe transaction.\n     * @param prevModule Previous module in the modules linked list.\n     * @param module Module to be removed.\n     */\n    function disableModule(address prevModule, address module) public authorized {\n        // Validate module address and check that it corresponds to module index.\n        require(module != address(0) && module != SENTINEL_MODULES, \"GS101\");\n        require(modules[prevModule] == module, \"GS103\");\n        modules[prevModule] = modules[module];\n        modules[module] = address(0);\n        emit DisabledModule(module);\n    }\n\n    /**\n     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token)\n     * @dev Function is virtual to allow overriding for L2 singleton to emit an event for indexing.\n     * @param to Destination address of module transaction.\n     * @param value Ether value of module transaction.\n     * @param data Data payload of module transaction.\n     * @param operation Operation type of module transaction.\n     * @return success Boolean flag indicating if the call succeeded.\n     */\n    function execTransactionFromModule(\n        address to,\n        uint256 value,\n        bytes memory data,\n        Enum.Operation operation\n    ) public virtual returns (bool success) {\n        // Only whitelisted modules are allowed.\n        require(msg.sender != SENTINEL_MODULES && modules[msg.sender] != address(0), \"GS104\");\n        // Execute transaction without further confirmations.\n        success = execute(to, value, data, operation, type(uint256).max);\n        if (success) emit ExecutionFromModuleSuccess(msg.sender);\n        else emit ExecutionFromModuleFailure(msg.sender);\n    }\n\n    /**\n     * @notice Execute `operation` (0: Call, 1: DelegateCall) to `to` with `value` (Native Token) and return data\n     * @param to Destination address of module transaction.\n     * @param value Ether value of module transaction.\n     * @param data Data payload of module transaction.\n     * @param operation Operation type of module transaction.\n     * @return success Boolean flag indicating if the call succeeded.\n     * @return returnData Data returned by the call.\n     */\n    function execTransactionFromModuleReturnData(\n        address to,\n        uint256 value,\n        bytes memory data,\n        Enum.Operation operation\n    ) public returns (bool success, bytes memory returnData) {\n        success = execTransactionFromModule(to, value, data, operation);\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // Load free memory location\n            let ptr := mload(0x40)\n            // We allocate memory for the return data by setting the free memory location to\n            // current free memory location + data size + 32 bytes for data size value\n            mstore(0x40, add(ptr, add(returndatasize(), 0x20)))\n            // Store the size\n            mstore(ptr, returndatasize())\n            // Store the data\n            returndatacopy(add(ptr, 0x20), 0, returndatasize())\n            // Point the return data to the correct memory location\n            returnData := ptr\n        }\n    }\n\n    /**\n     * @notice Returns if an module is enabled\n     * @return True if the module is enabled\n     */\n    function isModuleEnabled(address module) public view returns (bool) {\n        return SENTINEL_MODULES != module && modules[module] != address(0);\n    }\n\n    /**\n     * @notice Returns an array of modules.\n     *         If all entries fit into a single page, the next pointer will be 0x1.\n     *         If another page is present, next will be the last element of the returned array.\n     * @param start Start of the page. Has to be a module or start pointer (0x1 address)\n     * @param pageSize Maximum number of modules that should be returned. Has to be > 0\n     * @return array Array of modules.\n     * @return next Start of the next page.\n     */\n    function getModulesPaginated(address start, uint256 pageSize) external view returns (address[] memory array, address next) {\n        require(start == SENTINEL_MODULES || isModuleEnabled(start), \"GS105\");\n        require(pageSize > 0, \"GS106\");\n        // Init array with max page size\n        array = new address[](pageSize);\n\n        // Populate return array\n        uint256 moduleCount = 0;\n        next = modules[start];\n        while (next != address(0) && next != SENTINEL_MODULES && moduleCount < pageSize) {\n            array[moduleCount] = next;\n            next = modules[next];\n            moduleCount++;\n        }\n\n        /**\n          Because of the argument validation, we can assume that the loop will always iterate over the valid module list values\n          and the `next` variable will either be an enabled module or a sentinel address (signalling the end). \n          \n          If we haven't reached the end inside the loop, we need to set the next pointer to the last element of the modules array\n          because the `next` variable (which is a module by itself) acting as a pointer to the start of the next page is neither \n          included to the current page, nor will it be included in the next one if you pass it as a start.\n        */\n        if (next != SENTINEL_MODULES) {\n            next = array[moduleCount - 1];\n        }\n        // Set correct size of returned array\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            mstore(array, moduleCount)\n        }\n    }\n\n    /**\n     * @notice Returns true if `account` is a contract.\n     * @dev This function will return false if invoked during the constructor of a contract,\n     *      as the code is not actually created until after the constructor finishes.\n     * @param account The address being queried\n     */\n    function isContract(address account) internal view returns (bool) {\n        uint256 size;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            size := extcodesize(account)\n        }\n        return size > 0;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/base/OwnerManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/SelfAuthorized.sol\";\n\n/**\n * @title OwnerManager - Manages Safe owners and a threshold to authorize transactions.\n * @dev Uses a linked list to store the owners because the code generate by the solidity compiler\n *      is more efficient than using a dynamic array.\n * @author Stefan George - @Georgi87\n * @author Richard Meissner - @rmeissner\n */\nabstract contract OwnerManager is SelfAuthorized {\n    event AddedOwner(address indexed owner);\n    event RemovedOwner(address indexed owner);\n    event ChangedThreshold(uint256 threshold);\n\n    address internal constant SENTINEL_OWNERS = address(0x1);\n\n    mapping(address => address) internal owners;\n    uint256 internal ownerCount;\n    uint256 internal threshold;\n\n    /**\n     * @notice Sets the initial storage of the contract.\n     * @param _owners List of Safe owners.\n     * @param _threshold Number of required confirmations for a Safe transaction.\n     */\n    function setupOwners(address[] memory _owners, uint256 _threshold) internal {\n        // Threshold can only be 0 at initialization.\n        // Check ensures that setup function can only be called once.\n        require(threshold == 0, \"GS200\");\n        // Validate that threshold is smaller than number of added owners.\n        require(_threshold <= _owners.length, \"GS201\");\n        // There has to be at least one Safe owner.\n        require(_threshold >= 1, \"GS202\");\n        // Initializing Safe owners.\n        address currentOwner = SENTINEL_OWNERS;\n        for (uint256 i = 0; i < _owners.length; i++) {\n            // Owner address cannot be null.\n            address owner = _owners[i];\n            require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this) && currentOwner != owner, \"GS203\");\n            // No duplicate owners allowed.\n            require(owners[owner] == address(0), \"GS204\");\n            owners[currentOwner] = owner;\n            currentOwner = owner;\n        }\n        owners[currentOwner] = SENTINEL_OWNERS;\n        ownerCount = _owners.length;\n        threshold = _threshold;\n    }\n\n    /**\n     * @notice Adds the owner `owner` to the Safe and updates the threshold to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param owner New owner address.\n     * @param _threshold New threshold.\n     */\n    function addOwnerWithThreshold(address owner, uint256 _threshold) public authorized {\n        // Owner address cannot be null, the sentinel or the Safe itself.\n        require(owner != address(0) && owner != SENTINEL_OWNERS && owner != address(this), \"GS203\");\n        // No duplicate owners allowed.\n        require(owners[owner] == address(0), \"GS204\");\n        owners[owner] = owners[SENTINEL_OWNERS];\n        owners[SENTINEL_OWNERS] = owner;\n        ownerCount++;\n        emit AddedOwner(owner);\n        // Change threshold if threshold was changed.\n        if (threshold != _threshold) changeThreshold(_threshold);\n    }\n\n    /**\n     * @notice Removes the owner `owner` from the Safe and updates the threshold to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param prevOwner Owner that pointed to the owner to be removed in the linked list\n     * @param owner Owner address to be removed.\n     * @param _threshold New threshold.\n     */\n    function removeOwner(address prevOwner, address owner, uint256 _threshold) public authorized {\n        // Only allow to remove an owner, if threshold can still be reached.\n        require(ownerCount - 1 >= _threshold, \"GS201\");\n        // Validate owner address and check that it corresponds to owner index.\n        require(owner != address(0) && owner != SENTINEL_OWNERS, \"GS203\");\n        require(owners[prevOwner] == owner, \"GS205\");\n        owners[prevOwner] = owners[owner];\n        owners[owner] = address(0);\n        ownerCount--;\n        emit RemovedOwner(owner);\n        // Change threshold if threshold was changed.\n        if (threshold != _threshold) changeThreshold(_threshold);\n    }\n\n    /**\n     * @notice Replaces the owner `oldOwner` in the Safe with `newOwner`.\n     * @dev This can only be done via a Safe transaction.\n     * @param prevOwner Owner that pointed to the owner to be replaced in the linked list\n     * @param oldOwner Owner address to be replaced.\n     * @param newOwner New owner address.\n     */\n    function swapOwner(address prevOwner, address oldOwner, address newOwner) public authorized {\n        // Owner address cannot be null, the sentinel or the Safe itself.\n        require(newOwner != address(0) && newOwner != SENTINEL_OWNERS && newOwner != address(this), \"GS203\");\n        // No duplicate owners allowed.\n        require(owners[newOwner] == address(0), \"GS204\");\n        // Validate oldOwner address and check that it corresponds to owner index.\n        require(oldOwner != address(0) && oldOwner != SENTINEL_OWNERS, \"GS203\");\n        require(owners[prevOwner] == oldOwner, \"GS205\");\n        owners[newOwner] = owners[oldOwner];\n        owners[prevOwner] = newOwner;\n        owners[oldOwner] = address(0);\n        emit RemovedOwner(oldOwner);\n        emit AddedOwner(newOwner);\n    }\n\n    /**\n     * @notice Changes the threshold of the Safe to `_threshold`.\n     * @dev This can only be done via a Safe transaction.\n     * @param _threshold New threshold.\n     */\n    function changeThreshold(uint256 _threshold) public authorized {\n        // Validate that threshold is smaller than number of owners.\n        require(_threshold <= ownerCount, \"GS201\");\n        // There has to be at least one Safe owner.\n        require(_threshold >= 1, \"GS202\");\n        threshold = _threshold;\n        emit ChangedThreshold(threshold);\n    }\n\n    /**\n     * @notice Returns the number of required confirmations for a Safe transaction aka the threshold.\n     * @return Threshold number.\n     */\n    function getThreshold() public view returns (uint256) {\n        return threshold;\n    }\n\n    /**\n     * @notice Returns if `owner` is an owner of the Safe.\n     * @return Boolean if owner is an owner of the Safe.\n     */\n    function isOwner(address owner) public view returns (bool) {\n        return owner != SENTINEL_OWNERS && owners[owner] != address(0);\n    }\n\n    /**\n     * @notice Returns a list of Safe owners.\n     * @return Array of Safe owners.\n     */\n    function getOwners() public view returns (address[] memory) {\n        address[] memory array = new address[](ownerCount);\n\n        // populate return array\n        uint256 index = 0;\n        address currentOwner = owners[SENTINEL_OWNERS];\n        while (currentOwner != SENTINEL_OWNERS) {\n            array[index] = currentOwner;\n            currentOwner = owners[currentOwner];\n            index++;\n        }\n        return array;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/base/FallbackManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/SelfAuthorized.sol\";\n\n/**\n * @title Fallback Manager - A contract managing fallback calls made to this contract\n * @author Richard Meissner - @rmeissner\n */\nabstract contract FallbackManager is SelfAuthorized {\n    event ChangedFallbackHandler(address indexed handler);\n\n    // keccak256(\"fallback_manager.handler.address\")\n    bytes32 internal constant FALLBACK_HANDLER_STORAGE_SLOT = 0x6c9a6c4a39284e37ed1cf53d337577d14212a4870fb976a4366c693b939918d5;\n\n    /**\n     *  @notice Internal function to set the fallback handler.\n     *  @param handler contract to handle fallback calls.\n     */\n    function internalSetFallbackHandler(address handler) internal {\n        /*\n            If a fallback handler is set to self, then the following attack vector is opened:\n            Imagine we have a function like this:\n            function withdraw() internal authorized {\n                withdrawalAddress.call.value(address(this).balance)(\"\");\n            }\n\n            If the fallback method is triggered, the fallback handler appends the msg.sender address to the calldata and calls the fallback handler.\n            A potential attacker could call a Safe with the 3 bytes signature of a withdraw function. Since 3 bytes do not create a valid signature,\n            the call would end in a fallback handler. Since it appends the msg.sender address to the calldata, the attacker could craft an address \n            where the first 3 bytes of the previous calldata + the first byte of the address make up a valid function signature. The subsequent call would result in unsanctioned access to Safe's internal protected methods.\n            For some reason, solidity matches the first 4 bytes of the calldata to a function signature, regardless if more data follow these 4 bytes.\n        */\n        require(handler != address(this), \"GS400\");\n\n        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, handler)\n        }\n    }\n\n    /**\n     * @notice Set Fallback Handler to `handler` for the Safe.\n     * @dev Only fallback calls without value and with data will be forwarded.\n     *      This can only be done via a Safe transaction.\n     *      Cannot be set to the Safe itself.\n     * @param handler contract to handle fallback calls.\n     */\n    function setFallbackHandler(address handler) public authorized {\n        internalSetFallbackHandler(handler);\n        emit ChangedFallbackHandler(handler);\n    }\n\n    // @notice Forwards all calls to the fallback handler if set. Returns 0 if no handler is set.\n    // @dev Appends the non-padded caller address to the calldata to be optionally used in the handler\n    //      The handler can make us of `HandlerContext.sol` to extract the address.\n    //      This is done because in the next call frame the `msg.sender` will be FallbackManager's address\n    //      and having the original caller address may enable additional verification scenarios.\n    // solhint-disable-next-line payable-fallback,no-complex-fallback\n    fallback() external {\n        bytes32 slot = FALLBACK_HANDLER_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let handler := sload(slot)\n            if iszero(handler) {\n                return(0, 0)\n            }\n            calldatacopy(0, 0, calldatasize())\n            // The msg.sender address is shifted to the left by 12 bytes to remove the padding\n            // Then the address without padding is stored right after the calldata\n            mstore(calldatasize(), shl(96, caller()))\n            // Add 20 bytes for the address appended add the end\n            let success := call(gas(), handler, 0, 0, add(calldatasize(), 20), 0, 0)\n            returndatacopy(0, 0, returndatasize())\n            if iszero(success) {\n                revert(0, returndatasize())\n            }\n            return(0, returndatasize())\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/base/GuardManager.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\nimport \"../common/Enum.sol\";\nimport \"../common/SelfAuthorized.sol\";\nimport \"../interfaces/IERC165.sol\";\n\ninterface Guard is IERC165 {\n    function checkTransaction(\n        address to,\n        uint256 value,\n        bytes memory data,\n        Enum.Operation operation,\n        uint256 safeTxGas,\n        uint256 baseGas,\n        uint256 gasPrice,\n        address gasToken,\n        address payable refundReceiver,\n        bytes memory signatures,\n        address msgSender\n    ) external;\n\n    function checkAfterExecution(bytes32 txHash, bool success) external;\n}\n\nabstract contract BaseGuard is Guard {\n    function supportsInterface(bytes4 interfaceId) external view virtual override returns (bool) {\n        return\n            interfaceId == type(Guard).interfaceId || // 0xe6d7a83a\n            interfaceId == type(IERC165).interfaceId; // 0x01ffc9a7\n    }\n}\n\n/**\n * @title Guard Manager - A contract managing transaction guards which perform pre and post-checks on Safe transactions.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract GuardManager is SelfAuthorized {\n    event ChangedGuard(address indexed guard);\n\n    // keccak256(\"guard_manager.guard.address\")\n    bytes32 internal constant GUARD_STORAGE_SLOT = 0x4a204f620c8c5ccdca3fd54d003badd85ba500436a431f0cbda4f558c93c34c8;\n\n    /**\n     * @dev Set a guard that checks transactions before execution\n     *      This can only be done via a Safe transaction.\n     *      ⚠️ IMPORTANT: Since a guard has full power to block Safe transaction execution,\n     *        a broken guard can cause a denial of service for the Safe. Make sure to carefully\n     *        audit the guard code and design recovery mechanisms.\n     * @notice Set Transaction Guard `guard` for the Safe. Make sure you trust the guard.\n     * @param guard The address of the guard to be used or the 0 address to disable the guard\n     */\n    function setGuard(address guard) external authorized {\n        if (guard != address(0)) {\n            require(Guard(guard).supportsInterface(type(Guard).interfaceId), \"GS300\");\n        }\n        bytes32 slot = GUARD_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            sstore(slot, guard)\n        }\n        emit ChangedGuard(guard);\n    }\n\n    /**\n     * @dev Internal method to retrieve the current guard\n     *      We do not have a public method because we're short on bytecode size limit,\n     *      to retrieve the guard address, one can use `getStorageAt` from `StorageAccessible` contract\n     *      with the slot `GUARD_STORAGE_SLOT`\n     * @return guard The address of the guard\n     */\n    function getGuard() internal view returns (address guard) {\n        bytes32 slot = GUARD_STORAGE_SLOT;\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            guard := sload(slot)\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/NativeCurrencyPaymentFallback.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title NativeCurrencyPaymentFallback - A contract that has a fallback to accept native currency payments.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract NativeCurrencyPaymentFallback {\n    event SafeReceived(address indexed sender, uint256 value);\n\n    /**\n     * @notice Receive function accepts native currency transactions.\n     * @dev Emits an event with sender and received value.\n     */\n    receive() external payable {\n        emit SafeReceived(msg.sender, msg.value);\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/Singleton.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Singleton - Base for singleton contracts (should always be the first super contract)\n *        This contract is tightly coupled to our proxy contract (see `proxies/SafeProxy.sol`)\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Singleton {\n    // singleton always has to be the first declared variable to ensure the same location as in the Proxy contract.\n    // It should also always be ensured the address is stored alone (uses a full word)\n    address private singleton;\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/SignatureDecoder.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SignatureDecoder - Decodes signatures encoded as bytes\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SignatureDecoder {\n    /**\n     * @notice Splits signature bytes into `uint8 v, bytes32 r, bytes32 s`.\n     * @dev Make sure to perform a bounds check for @param pos, to avoid out of bounds access on @param signatures\n     *      The signature format is a compact form of {bytes32 r}{bytes32 s}{uint8 v}\n     *      Compact means uint8 is not padded to 32 bytes.\n     * @param pos Which signature to read.\n     *            A prior bounds check of this parameter should be performed, to avoid out of bounds access.\n     * @param signatures Concatenated {r, s, v} signatures.\n     * @return v Recovery ID or Safe signature type.\n     * @return r Output value r of the signature.\n     * @return s Output value s of the signature.\n     */\n    function signatureSplit(bytes memory signatures, uint256 pos) internal pure returns (uint8 v, bytes32 r, bytes32 s) {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let signaturePos := mul(0x41, pos)\n            r := mload(add(signatures, add(signaturePos, 0x20)))\n            s := mload(add(signatures, add(signaturePos, 0x40)))\n            /**\n             * Here we are loading the last 32 bytes, including 31 bytes\n             * of 's'. There is no 'mload8' to do this.\n             * 'byte' is not working due to the Solidity parser, so lets\n             * use the second best option, 'and'\n             */\n            v := and(mload(add(signatures, add(signaturePos, 0x41))), 0xff)\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/SecuredTokenTransfer.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SecuredTokenTransfer - Secure token transfer.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SecuredTokenTransfer {\n    /**\n     * @notice Transfers a token and returns a boolean if it was a success\n     * @dev It checks the return data of the transfer call and returns true if the transfer was successful.\n     *      It doesn't check if the `token` address is a contract or not.\n     * @param token Token that should be transferred\n     * @param receiver Receiver to whom the token should be transferred\n     * @param amount The amount of tokens that should be transferred\n     * @return transferred Returns true if the transfer was successful\n     */\n    function transferToken(address token, address receiver, uint256 amount) internal returns (bool transferred) {\n        // 0xa9059cbb - keccack(\"transfer(address,uint256)\")\n        bytes memory data = abi.encodeWithSelector(0xa9059cbb, receiver, amount);\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            // We write the return value to scratch space.\n            // See https://docs.soliditylang.org/en/v0.7.6/internals/layout_in_memory.html#layout-in-memory\n            let success := call(sub(gas(), 10000), token, 0, add(data, 0x20), mload(data), 0, 0x20)\n            switch returndatasize()\n            case 0 {\n                transferred := success\n            }\n            case 0x20 {\n                transferred := iszero(or(iszero(success), iszero(mload(0))))\n            }\n            default {\n                transferred := 0\n            }\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/StorageAccessible.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title StorageAccessible - A generic base contract that allows callers to access all internal storage.\n * @notice See https://github.com/gnosis/util-contracts/blob/bb5fe5fb5df6d8400998094fb1b32a178a47c3a1/contracts/StorageAccessible.sol\n *         It removes a method from the original contract not needed for the Safe contracts.\n * @author Gnosis Developers\n */\nabstract contract StorageAccessible {\n    /**\n     * @notice Reads `length` bytes of storage in the currents contract\n     * @param offset - the offset in the current contract's storage in words to start reading from\n     * @param length - the number of words (32 bytes) of data to read\n     * @return the bytes that were read.\n     */\n    function getStorageAt(uint256 offset, uint256 length) public view returns (bytes memory) {\n        bytes memory result = new bytes(length * 32);\n        for (uint256 index = 0; index < length; index++) {\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                let word := sload(add(offset, index))\n                mstore(add(add(result, 0x20), mul(index, 0x20)), word)\n            }\n        }\n        return result;\n    }\n\n    /**\n     * @dev Performs a delegatecall on a targetContract in the context of self.\n     * Internally reverts execution to avoid side effects (making it static).\n     *\n     * This method reverts with data equal to `abi.encode(bool(success), bytes(response))`.\n     * Specifically, the `returndata` after a call to this method will be:\n     * `success:bool || response.length:uint256 || response:bytes`.\n     *\n     * @param targetContract Address of the contract containing the code to execute.\n     * @param calldataPayload Calldata that should be sent to the target contract (encoded method name and arguments).\n     */\n    function simulateAndRevert(address targetContract, bytes memory calldataPayload) external {\n        // solhint-disable-next-line no-inline-assembly\n        assembly {\n            let success := delegatecall(gas(), targetContract, add(calldataPayload, 0x20), mload(calldataPayload), 0, 0)\n\n            mstore(0x00, success)\n            mstore(0x20, returndatasize())\n            returndatacopy(0x40, 0, returndatasize())\n            revert(0, add(returndatasize(), 0x40))\n        }\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/external/SafeMath.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SafeMath\n * @notice Math operations with safety checks that revert on error (overflow/underflow)\n */\nlibrary SafeMath {\n    /**\n     * @notice Multiplies two numbers, reverts on overflow.\n     * @param a First number\n     * @param b Second number\n     * @return Product of a and b\n     */\n    function mul(uint256 a, uint256 b) internal pure returns (uint256) {\n        // Gas optimization: this is cheaper than requiring 'a' not being zero, but the\n        // benefit is lost if 'b' is also tested.\n        // See: https://github.com/OpenZeppelin/openzeppelin-solidity/pull/522\n        if (a == 0) {\n            return 0;\n        }\n\n        uint256 c = a * b;\n        require(c / a == b);\n\n        return c;\n    }\n\n    /**\n     * @notice Subtracts two numbers, reverts on overflow (i.e. if subtrahend is greater than minuend).\n     * @param a First number\n     * @param b Second number\n     * @return Difference of a and b\n     */\n    function sub(uint256 a, uint256 b) internal pure returns (uint256) {\n        require(b <= a);\n        uint256 c = a - b;\n\n        return c;\n    }\n\n    /**\n     * @notice Adds two numbers, reverts on overflow.\n     * @param a First number\n     * @param b Second number\n     * @return Sum of a and b\n     */\n    function add(uint256 a, uint256 b) internal pure returns (uint256) {\n        uint256 c = a + b;\n        require(c >= a);\n\n        return c;\n    }\n\n    /**\n     * @notice Returns the largest of two numbers.\n     * @param a First number\n     * @param b Second number\n     * @return Largest of a and b\n     */\n    function max(uint256 a, uint256 b) internal pure returns (uint256) {\n        return a >= b ? a : b;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/Enum.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title Enum - Collection of enums used in Safe contracts.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Enum {\n    enum Operation {\n        Call,\n        DelegateCall\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/common/SelfAuthorized.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\n\n/**\n * @title SelfAuthorized - Authorizes current contract to perform actions to itself.\n * @author Richard Meissner - @rmeissner\n */\nabstract contract SelfAuthorized {\n    function requireSelfCall() private view {\n        require(msg.sender == address(this), \"GS031\");\n    }\n\n    modifier authorized() {\n        // Modifiers are copied around during compilation. This is a function call as it minimized the bytecode size\n        requireSelfCall();\n        _;\n    }\n}\n"
      },
      "lib/composable-cow/lib/safe/contracts/base/Executor.sol": {
        "content": "// SPDX-License-Identifier: LGPL-3.0-only\npragma solidity >=0.7.0 <0.9.0;\nimport \"../common/Enum.sol\";\n\n/**\n * @title Executor - A contract that can execute transactions\n * @author Richard Meissner - @rmeissner\n */\nabstract contract Executor {\n    /**\n     * @notice Executes either a delegatecall or a call with provided parameters.\n     * @dev This method doesn't perform any sanity check of the transaction, such as:\n     *      - if the contract at `to` address has code or not\n     *      It is the responsibility of the caller to perform such checks.\n     * @param to Destination address.\n     * @param value Ether value.\n     * @param data Data payload.\n     * @param operation Operation type.\n     * @return success boolean flag indicating if the call succeeded.\n     */\n    function execute(\n        address to,\n        uint256 value,\n        bytes memory data,\n        Enum.Operation operation,\n        uint256 txGas\n    ) internal returns (bool success) {\n        if (operation == Enum.Operation.DelegateCall) {\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                success := delegatecall(txGas, to, add(data, 0x20), mload(data), 0, 0)\n            }\n        } else {\n            // solhint-disable-next-line no-inline-assembly\n            assembly {\n                success := call(txGas, to, value, add(data, 0x20), mload(data), 0, 0)\n            }\n        }\n    }\n}\n"
      }
    },
    "settings": {
      "remappings": [
        "lib/composable-cow:cowprotocol/=lib/composable-cow/lib/cowprotocol/src/contracts/",
        "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/",
        "@openzeppelin/=lib/composable-cow/lib/@openzeppelin/",
        "@openzeppelin/contracts/=lib/composable-cow/lib/@openzeppelin/contracts/",
        "balancer/=lib/composable-cow/lib/balancer/src/",
        "canonical-weth/=lib/composable-cow/lib/canonical-weth/src/",
        "composable-cow/=lib/composable-cow/",
        "cowprotocol/=lib/composable-cow/lib/cowprotocol/",
        "ds-test/=lib/forge-std/lib/ds-test/src/",
        "erc4626-tests/=lib/openzeppelin/lib/erc4626-tests/",
        "forge-std/=lib/forge-std/src/",
        "helpers/=lib/composable-cow/lib/balancer/src/lib/helpers/",
        "math/=lib/composable-cow/lib/balancer/src/lib/math/",
        "murky/=lib/composable-cow/lib/murky/src/",
        "openzeppelin-contracts/=lib/composable-cow/lib/canonical-weth/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": {}
    }
  }}