Merge Settlement contract and uni v4

Cow protocol has a gas overhead compared with trading only an AMM directly, if not sufficient trades are settled in one batch. The gas overhead is mostly given by the additional transfers between the user account, the settlement contract and the AMMs.

I think this can be partly reduced, if one implements the logic of the settlement contract as a pre_hook and post_hook of uni v4. Of course, it is only a gas-saving, if one later trades against univ4, but I guess most trades are going through univ4 in a year.

There is also an additional overhead of one unnecessary AMM for which the pre_hook and post_hooks implement the settlement logic. But I guess this is easily outweighed by the benefits, though I have not done the exact math.

Wdyt? Would it be worth it?


This is an interesting proposition. Could you elaborate on how concretely an integration with Uni v4 hooks would look like?

I understand the proposition of sending the sellToken directly from user → uni v4 singleton (to alleviate the extra transfer hop via the settlement contract). In fact sending the sell_token directly to arbitrary recipients is something, we’d definitely want to support in an updated version of the settlement contract.

The part I have a hard time understanding is what would the pre/post hook logic look like (roughly speaking) and how would we be able to alleviate the post-trade transfer (afaik Uniswap doesn’t allow specifying a receiver and always sends funds to msg.sender)?