Vote with your governance tokens while providing liquidity to Uniswap v4
Delegated Liquidity is a Uniswap v4 Hook that allows holders of DAO governance tokens to provide liquidity while retaining the right to participate in governance votes with their share of tokens in the pool.
Normally, when a holder of a governance token deposits them into a DeFi protocol, they lose the ability to vote with those tokens. That's because the tokens are held by protocol—such as the pool contract in the case of Uniswap—and the governance contracts no longer recognize the LP's ownership of them as a result.
Flexible Voting is an extension to the standard DAO governance contracts that allows for voting integrations to be built which overcome this limitation. It was developed by ScopeLift and has been adopted by real DAOs, including Gitcoin, PoolTogether, and Frax Finance.
By leveraging Flexible Voting and v4 Hooks, we built a Pool that enables governance token holders to LP without losing their voting rights.
For this hackathon, we leveraged Uniswap v4 Hooks and Flexible Voting to develop a Pool that will allow LPs to vote with their share of the Pool's liquidity. Thanks to hooks, we can do this permissionlessly. When an LP creates or modifies a position, or when a user executes a swap, the Delegated Liquidity contracts we developed for this hackathon receive a callback. We use this callback to record checkpointed data about the state of the Pool and the LP's positions in it.
By tracking these changes to the Pool's state, we can calculate the share of the tokens any given LP has a claim to at any given time. You can think of this calculation in this way: if the LP were to close their position right now, how many governance tokens would they be entitled to? That number represents the share of Pool's liquidity the LP ought to be able vote with.
The Delegated Liquidity contract allows LPs to express their vote for their share of the tokens, and records these votes internally. Finally, the Delegated Liquidity contract passes the votes of all LPs forward to the Governor contract by leveraging the Flexible Voting extension, which enables fractional voting by delegates. In this case, the Delegated Liquidity acts as the voting delegate on behalf of the Pool.
The contracts were built and tested using Foundry and the Uniswap v4 development template. We the hook contract and the integration with governance, along with tests which simulate the process of an LP voting on an active proposal with their share of the liquidity.