Grant Application: Concentrated liquidity CoW AMM + Rehypothecation-adapter

Author:

Yevhen Liubchenko
Twitter: yevhenx
GitHub: leooos33

Ivan Volovyk
Twitter: LisVikkk
GitHub: ivanvolov

About us:

Yevhen Liubchenko

  • B.A. in Mechanical Engineering, M.A. in Economics
  • Project Owner (Node-as-a-Service) at Minter (2019-2021)
  • Quantitative Researcher at JMT (2018-2019)

Ivan Volovyk

  • B.A. in Computer Science, M.A. in Economics
  • Supply Chain Data Engineer at Soley (2020-2022)
  • Solidity Developer at MadFish (2018-2020)

Team Experience

  • Liqui Hedgehog (2022-2023): Developed a synthetic ETH vault that provided liquidity on Uniswap V3 and hedged its impermanent loss using Squeeth power perpetuals (project was shut down due to Squeeth’s legal issues).
  • Winners of Uniswap V4 Hookathon 2: Created a rehypothecation hook for maximizing stablecoin yield.
  • Winners of Uniswap V4 Hookathon 1: Developed hook-based options.
  • Winners of HackDefi with Wintermute (2021): Built a customizable hook DEX (proto Uniswap V4).

Our goal is to improve capital efficiency, mitigate LVR, and increase yield for liquidity providers. We have developed a prototype of the Concentrated CoW AMM and now seek a grant to bring it to production, enhancing liquidity tools in the CoW ecosystem.

Additional Links:

Due to the link limit for new users, here is the document with all the additional links - Link

Grant Category:

Integrations and protocol order flow

Grant Description:

The project consists of 2 main components: Rehypothecation Adapter and Concentrated Liquidity CoW AMM.

Rehypothecation Adapter

The Rehypothecation Adapter serves as a base contract with a custom trading function that deploys all of the AMM liquidity into lending protocols to earn additional low-risk yield while preserving liquidity for trade execution.

For example, in the case of the ETH-USDC CoW AMM it will be:

  1. The contract deposit both ETH and USDC as collateral on lending protocol (e.g., AAVE)
  2. We receive ETH from the user for the ETH → USDC swap operation
  3. In pre-hook: Calculate amount of USDC that we owe to the user and withdraw this amount from lending protocol
  4. Execute the swap
  5. In post-hook: Increase our collateral

This way, by executing on-demand lending protocol deposits/withdrawals, we significantly boost overall LP returns by collecting both trading fees and interest rate payments.

From the technical integration perspective, this adapter standardizes integration flow for solvers, enabling efficient deposits/withdrawals management while maintaining compatibility with multiple lending protocols without redeployment rather than dealing with manual integration of aTokens-like entities.

Concentrated Liquidity CoW AMM

The second component is Concentrated Liquidity CoW AMM as an enhancement of the original CoW AMM. By integrating a well-known concentrated liquidity model, it enables LPs to significantly improve their capital efficiency and potential returns. By allowing LPs to allocate their capital within specific price ranges where trading activity is highest, this model optimizes fund utilization and increases fee earnings while maintaining MEV-protection following the original CoW AMM approach.

This advancement is crucial for providing deeper liquidity around key market prices and enhancing the returns for liquidity providers in both stablecoin, synthetic asset and volatile asset pools.

Together these 2 products will form a flexible liquidity deployment platform where LPs will be able to choose from multiple AMM options:

  • CoW AMM
  • CoW AMM with Rehypothecation
  • Concentrated liquidity CoW AMM
  • Concentrated liquidity CoW AMM with Rehypothecation

Maximizing flexibility and capital-efficiency for LPs, while preserving protection from MEV exploits. Which in turn, will improve trade execution for the end-users bringing more trading fees and liquidity into the CoW ecosystem.


We have already developed a prototype of the Concentrated Liquidity CoW AMM and are now seeking a grant to bring it to production along with the Rehypothecation Adapter.

Grant Goals and Impact:

The primary goal of this grant is to bring the Concentrated Liquidity CoW AMM and Rehypothecation Adapter from prototype to production, creating a flexible and robust liquidity deployment platform for LPs in the CoW ecosystem. Specifically, we aim to:

  • Develop a Multi-Option AMM Platform: Allow LPs to deploy liquidity into one of several AMM configurations: CoW AMM, Concentrated Liquidity CoW AMM, CoW AMM with Rehypothecation, or Concentrated Liquidity CoW AMM with Rehypothecation. This flexibility maximizes customization and efficiency for LPs, aligning their strategies with market conditions and yield opportunities.
  • Integrate Rehypothecation for Additional Yield: Enable liquidity pools to earn low-risk yields by deploying liquidity into lending protocols while maintaining on-demand liquidity through automatic deposit and withdrawal mechanisms. This ensures LPs can benefit from both trading fees and yield generation without compromising liquidity.
  • Enhance Liquidity, Efficiency, and User Experience: Increase liquidity in stablecoin and pegged asset pools, enhance MEV protection, and streamline the liquidity management experience for both LPs and solvers, leading to more efficient capital utilization and reduced LVR risks.

By bringing these components to production, we aim to significantly improve the efficiency of the CoW Protocol, providing LPs with optimized returns, users with better trading conditions, and the overall ecosystem with enhanced liquidity provisioning options.

We believe that a combination of Rehypothecation + Concentrated Liquidity model will bring a lot of liquidity into the CoW ecosystem, especially for stablecoin and pegged asset pools by offering significantly improved LP returns compared to the existing solutions, like Curve and Uniswap V3.

Milestones:

Milestone Due date Payment
Rehypothecation Adapter (RA) 6 weeks 30k xDAI
RA Testnet Validation 1 week 10k xDAI
Concentrated liquidity CoW AMM (CL) 6 weeks -
CL Testnet Validation 1 week 10k xDAI

As we already have developed the MVP of the Concentrated liquidity CoW AMM, we’re requesting a 30k xDAI up-front and 10k xDAI upon completion of each milestone. See the Funding Request section.

Milestone 1

Description: Develop and integrate the Rehypothecation Adapter into the AMM framework. This includes deploying AMM liquidity into lending protocols to earn additional low-risk yield, while maintaining on-demand liquidity through automated withdrawal mechanisms. Initial supported lending protocols will include AAVE, Morpho, Euler.

  • Deliverables:
    • Smart contract development for the Rehypothecation Adapter.
    • Testnet deployment on Sepolia.

Milestone 2

Description: Complete the development of the Concentrated Liquidity CoW AMM prototype. This includes finalizing the integration of concentrated liquidity features, implementing upper and lower price bounds (sqrtPriceUpper and sqrtPriceLower), and ensuring compatibility with CoW settlement contracts. This milestone aims to deliver a fully functional prototype for initial testing.

  • Deliverables:
    • Smart contract development for concentrated liquidity.
    • Initial deployment on the Sepolia testnet for functional validation.
    • Deploy and test the integrated AMM + Rehypothecation Adapter on Sepolia.
    • Mainnet deployment

Funding Request:

Total Funding Request: 50k xDAI

Up-front:

  • 30k xDAI up-front payment for development, smart contract creation, and testing.

Post-completion:

  • 10k xDAI upon successful deployment of Rehypothecation Adapter with CoW AMM as a first available trading function.
  • 10k xDAI upon successful deployment of Concentrated Liquidity CoW trading function.

Budget Breakdown:

Budget Allocation: Smart contract development and testing

Gnosis Chain Address: 0xB4E906060EABc5F30299e8098B61e41496a7233c

Referral: We discussed this project with Felix Leupold @fleupold, who referred us to the grant program.

3 Likes

Thanks @yevhenx for your submission!

I find this proposal extremely interesting and potentially very useful for the CoW ecosystem.
I would signal my inclination to support but would like to mention several aspects which unfortunately I’m not very well positioned to evaluate myself.

  1. The rehypothecaiton module use of pre and post hooks might have some unforeseen consequences in case of failed execution of those parts of the trade - this needs to be evaluated and spec’d out in detail to remove any security concerns
  2. SC security and audits - At CoW we take security as top level priority. Such an initiative must include a detailed security evaluation and audit plans.
  3. In order to make such a project successful in practice, there must be wide solver support, which proved to be challenging. Would be great to see some thought about how to make solver integrations easy and viable.
  4. Additional aspect, is easy and polished interface for users to be able to deposit funds into LP positions. It’d be great to hear your thoughts about the effort required to create such frontend.
1 Like

Thanks @middleway.eth for your valuable feedback and support for our proposal! Below, we address the key concerns you raised in detail:

Rehypothecation Pre and Post-hooks: We understand the challenges of relying on pre- and post-hooks for rehypothecation, as their execution depends on solvers’ actions and can lead to risks if not properly handled. To mitigate these risks, we have designed specific mechanisms to ensure robustness:

  1. Pre-hook Execution: If the pre-hook is not executed, liquidity is not withdrawn from the lending pool, preventing the trade from proceeding. This guarantees that the pre-hook must execute for the trade to complete, safeguarding against incomplete transactions.
  2. Post-hook Execution: If the post-hook is not executed, the received liquidity remains idle rather than being returned to the lending pool, reducing potential yield. To address this, the subsequent trade’s pre-hook will detect and reinvest any remaining funds, ensuring the system self-corrects and yield opportunities are maximized.

These mechanisms ensure secure and reliable rehypothecation by enforcing critical checks during every trade, minimizing potential yield loss, and maintaining capital efficiency.

Security and Audits: We share your commitment to security and plan to request a follow-up grant exclusively for a comprehensive audit once the development and testing phases are completed. This audit will be conducted by a reputable third-party security firm or contest platform to ensure the highest standards of safety and risk management for our users.

Solver Integration: We recognize that broad solver integration is essential for the practical success of this project. To make solver integrations seamless, we will focus on standardizing communication between solvers and the rehypothecation and concentrated liquidity modules. Specifically, we will build a helper contract to provide a simple integration flow via easy-to-use interfaces and documentation for solvers. Inspired by the Balancer CoW AMM implementation, our helper contract will use a ‘surplus capturing’ approach, where solvers are expected to index and propose orders based on fair price inputs. This way, solvers can input the prices they consider fair, and the AMM will generate ready-to-execute orders based on internal trading functions (CoW AMM, Concentrated liquidity CoW AMM, etc).

Frontend Interface for User Deposits: Initially, during the testing and early launch phases, we plan to develop a minimalistic Safe-App interface for liquidity providers to deposit funds into LP positions. This simple interface will allow users to interact with the core functionalities of the AMM. Once all technical milestones are completed and the audit is conducted, we will expand the frontend to a production-ready state, focusing on usability, polished design, and ease of navigation. This step-by-step approach allows us to focus our resources on building secure contracts first, ensuring a safe and functional user experience.

We understand that this is a large and complex project, which is why we plan to split it into multiple steps. This phased approach will help ensure thorough evaluation and high-quality delivery at each stage, leading to a stable and successful implementation in the CoW ecosystem.

1 Like

Moved to Snapshot

Hi,
Sorry for the delays in response, things have been busy with Devcon and some time off.

Thanks for the detail submission. I too share some of the concerns in regards to those mentioned by @middleway.eth as well as some additional:

  1. Solver support is very, very difficult. Even with adaptors, getting solvers to support these kinds of instruments is very difficult and represents a high degree of risk that this project itself, while perhaps getting built, may remain very ineffective (worst case, receives on usage). For concrete research on this aspect, see [research] Calculating CoW AMM Trade Envy and Potential Missed Surplus.
  2. CoW AMMs, or FM-AMMs per the research paper, are hypothesized to be most beneficial on unstable pairs (i.e. pairs whereby the potential MEV risk is high, and therefore benefit from being contained within a batch auction). Therefore, I’m unsure about the potential benefit for this writ large in the CoW Swap ecosystem, and would like to see some weigh in from @AndreaC or @harisang from the solver team as to its potential benefits (or if they would indeed be limited).
  3. The methodology that has been outlined with regards to the pre and post hooks is sound, but does require very careful handling in order to make it effective. There are also potential gas concerns surrounding this (which in effect would act as a tax on pool, and therefore present some minimal TVL requirement in order for this to be sufficiently amortised). Getting some visibility into the team’s capability of enacting this is critical in order to determine the feasibility of the grant.
  4. The requested funds are, IMO, very much on the high side - especially with no previously completed grants for us to be able to objectively assess capabilities.

In general, I think it would be appropriate to

  1. Have weigh in from the solver team / mechanism team about the hypothesized benefits of concentrated liquidity.
  2. Divide the grant into multiple pieces, primarily informed by (1)
  3. Revised funding requested taking into account goal alignment between the grantee and CoW DAO (for such a large grant request, to request no $COW is somewhat misaligned IMO).

mfw78

In developing CoW AMM, CoW DAO has so far preferred not to develop the AMM infrastructure, and instead build integrations with existing AMM providers. My main concern with this proposal is that it seems to move in the opposite direction.

For example, Balancer V3 uses Liquidity Buffers. If the DAO were to continue its collaboration with Balancer and create a CoW AMM integration with Balancer V3, what would be an additional benefit of a standalone “CoW AMM with Rehypothecation”? Note also that, in theory, it is possible to create a CoW AMM on top of Uniswap v4. The authors of the proposal already created a rehypothecation hook for Uniswap v4. Again, what would be the advantage of a standalone “CoW AMM with Rehypothecation” when the DAO could deploy CoW AMM on Uni v4 and use the existing hook?

Similarly, what is the advantage of the Concentrated CoW AMM given the existing Balancer V3 / Uni v4 infrastructure?

To summarize: I would encourage the authors to explain the benefit of their proposal in relation to the alternative of building CoW AMM on top of existing AMM infrastructure.

Hi @mfw78 and @AndreaC,

Thank you for your thorough feedback. Based on your insights, we are revising our proposal to align more closely with CoW DAO’s integration strategy.

Solver Integration

We recognize that solver integration is indeed a challenging task, especially in the context of novel intent-based AMM architectures like Uniswap V4 and Balancer V3. In these setups, AMM developers must actively work on integrations to ensure sustainable trade flow for their custom trading logic. Applying the CoW AMM approach may be particularly beneficial in this regard, as it allows AMM developers to focus on building AMMs as self-rebalancing portfolios—a framework recently proposed by Andrea.

To support this, we propose an adapter that will help hook developers integrate their contracts with the CoW Protocol settlement contract.

Revised Proposal: Uniswap V4 and Balancer V3 Adapter

Given the CoW DAO’s strategy of leveraging existing AMM platforms, we have adjusted our proposal to focus on integrating with Uniswap V4 and Balancer V3. We propose building an adapter that will provide solvers with tradable orders compatible with the CoW Protocol settlement contract. This way, hook developers can easily integrate with the existing solvers network and achieve proposed earlier rehypothecation and concentrated liquidity features without building a standalone solution. Hence, helping LPs to benefit from the strengths of other AMM platforms while providing CoW-specific advantages such as batch auctions and MEV protection.

Grant Size and Structure

The revised proposal grant size will be $20k:

  • Uniswap V4 adapter: 5k xDAI upfront and 5k in COW tokens post-completion (3m vesting)
  • Balancer V3 adapter: 5k xDAI upfront and 5k in COW tokens post-completion (3m vesting)

We believe this revised direction better aligns with CoW DAO’s goals, leverages existing infrastructure, and maximizes value for the ecosystem. We look forward to further feedback, particularly from the solver team, to refine this proposal further.

Hi @yevhenx ,
Thanks for the revised proposal. Unlike the original proposal, the focus seems to be now on helping hook developers. This could be potentially super interesting, but I find it a bit unclear from your description how that would work. Can you provide an example of a hook that may leverage the integration you propose?