diff --git a/src/ConstantProductHelper.sol b/src/ConstantProductHelper.sol index 4e63c78..078938f 100644 --- a/src/ConstantProductHelper.sol +++ b/src/ConstantProductHelper.sol @@ -66,6 +66,7 @@ contract ConstantProductHelper is ICOWAMMPoolHelper, LegacyHelper { revert InvalidArrayLength(); } + bytes memory eip1271sig; if (!isLegacy(pool)) { // Standalone CoW AMMs (**non-Gnosis Safe Wallets**) if (!isCanonical(pool)) { @@ -93,7 +94,7 @@ contract ConstantProductHelper is ICOWAMMPoolHelper, LegacyHelper { }) ); - sig = abi.encode(_order); + eip1271sig = abi.encode(_order); preInteractions = new GPv2Interaction.Data[](1); preInteractions[0] = GPv2Interaction.Data({ @@ -102,8 +103,12 @@ contract ConstantProductHelper is ICOWAMMPoolHelper, LegacyHelper { callData: abi.encodeCall(ConstantProduct.commit, (_order.hash(SETTLEMENT.domainSeparator()))) }); } else { - (_order, preInteractions, postInteractions, sig) = legacyOrder(pool, prices); + (_order, preInteractions, postInteractions, eip1271sig) = legacyOrder(pool, prices); } + + // A ERC-1271 signature on CoW Protocol is composed of two parts: the + // signer address and the valid ERC-1271 signature data for that signer. + sig = abi.encodePacked(pool, eip1271sig); } /// @dev Take advantage of the mapping on the factory that is set to the owner's address for canonical pools. diff --git a/src/interfaces/ICOWAMMPoolHelper.sol b/src/interfaces/ICOWAMMPoolHelper.sol index 9ecd59e..8d00de6 100644 --- a/src/interfaces/ICOWAMMPoolHelper.sol +++ b/src/interfaces/ICOWAMMPoolHelper.sol @@ -65,7 +65,8 @@ interface ICOWAMMPoolHelper { * @return order The CoW Protocol JIT order * @return preInteractions The array array for any **PRE** interactions (empty if none) * @return postInteractions The array array for any **POST** interactions (empty if none) - * @return sig The ERC-1271 signature for the order + * @return sig A valid CoW-Protocol signature for the resulting order using + * the ERC-1271 signature scheme. */ function order(address pool, uint256[] calldata prices) external diff --git a/test/fork/ConstantProductHelper.t.sol b/test/fork/ConstantProductHelper.t.sol index 844bb67..353c556 100644 --- a/test/fork/ConstantProductHelper.t.sol +++ b/test/fork/ConstantProductHelper.t.sol @@ -87,12 +87,6 @@ contract ConstantProductHelperForkedTest is ForkedTest { GPv2Interaction.Data[] memory postInteractions; bytes memory sig; (ammOrder, preInteractions, postInteractions, sig) = helper.order(wethUsdcAmm, prices); - // The signature is valid for the contract but not for the - // settlement contract. We need to prepend the verifying contract - // address. - // TODO: update the helper so that it already includes the address in - // the signature. - sig = abi.encodePacked(wethUsdcAmm, sig); trades[0] = orderToFullTrade(ammOrder, tokens, GPv2Signing.Scheme.Eip1271, sig); // We expect a commit interaction in both pre and post interactions