Michael Wagner - Lessons Learned From Building UniswapV4 Hooks
EthereumZuri.ch 2024 · April 2024 · 9:42
At EthereumZuri.ch 2024, Michael Wagner shares lessons learned from building four Uniswap v4 hooks: liquidity incentives, dynamic fees, liquidity management and a combo hook. He walks through the challenges his team ran into, giving other DeFi builders a clear idea of what to expect and what to watch out for when developing hooks for the Uniswap v4 AMM.
Speakers
Topics
From EthereumZuri.ch 2024, hosted by EthereumZuri.ch.
Transcript
beautiful so hello everyone it's very weird to be in University that way but cool um so I'm Michael from Brer where we do automated liquid management and building some cool year strategies uh but today I'm here to talk about what we learned while we were building Uno V4 hooks because last year we received the Grant from Yo Foundation to build four V4 to build four PC hooks uh so just out of curious today how many of you have heard of Uno before and know what's up cool mostly all of you cool so I won't go into that much details um uni4 is launching later this year uh there are those three cool features like the
Singleton contract that consolidates all the contracts into one uh so the tokens don't have to transfer between the tokens between the contracts uh flesh accounting uh that change the transactions so further reducing the gas costs and finally the hooks uh there is I'm here um basically like the pull plugins similar to browser plugins that can completely change how the pool operates and there are some cool use cases like building an order book amm on top of un Swope uh doing native Bitcoin trading through Tor chain or kind combining or tying the mechanics of P or with the governance that directly with
the pool and much more like kyc to your pool right uh but from what we build um at brocker we focus on profitable liquidity management so that's what we wanted to do with the hooks as well so we build the liquidity locking and incentives so the user locks their liquidity and gets rewarded with tokens or nfts and also incentives will be a major tool to attract liquidity from the previous versions before so if you can expect lot of incentives programs on before when it launches um they also did the dynamic fees hook because liquidity providers are struggling with profit with profitability especially during High
volatility periods so the dynamic fees can completely change um like their profitability and can solve that um with our case or with our hook uh we did it through volume that we use as a proxy for vol ility so when volatility increases the volume increases or should increase and the fee increases as well um they also did liquidate management hook uh this one acts as an automated liquidate manager us user deposits liquidity into the pool or into the hook and the hook automatically manages uh the liquidity for them automatically rebalances and autoc compounds the fees and we also combined
the liquidate lock with the dynamic fees so the hook automatically adjusts the fees and lets the user lock their tokens and reward them this is especially interesting for Builders uh because this shows how you can combine multiple hooks together so you can build very complex even protocols on top of uniso which kind of makes it an infrastructure layer so it would be pretty cool to see what people will build on top of Unis swap right now but what did we learn um Details Matter this is especially important when you are combining hooks together um
because it's never as simple as you might think uh because you inherit all the good stuff all the bad stuff from the underlying Hooks and you need to align their features to kind of make it work in that one bigger hook so for example in the hook we were using in the combo hook you have the liquid locking and the combo and and the dynamic fees but so you when you look at it they're completely unrelated but it's not the case completely uh because we are using the unop function uh partial swaps for uh autoc compounding the fees in the liquated Locking
hook this is a feature that enables uh partial fils of the swaps so let's say you have a order for 1K but from some reason you will get an order on for $100 the whole order or it's recorded the volume is for 1K which is an issue if you have Dynamic fees hook that's based on volume and we had this function disabled on that hook so we had to redesign this feature to kind of fit both of those and this is just a simple example of two hooks that are completely unrelated if you have hooks that are more complicated they affect each other
this becomes much more complex much harder and you need to track a lot of things and make sure that their features are aligned otherwise it won't work as expected um but it's not only about the builders it's also about the protocols themselves uh because we are already seeing that Protocols are struggling with opening V3 pool and setting it up properly which is also the reason why majority of the pools or newly opened pools are opened on V2 instead of V3 and if you add hooks on top that's another layer of complexity and lot more moving parts that you have to set up and
somehow adjust and if you have no idea what you are doing this becomes more complicated and you might spend a lot of time doing some Theory crafting because there's also no best practice at the moment and multiple issues like the mvv stuff have multiple Solutions so for example the dynamic feeh hook that can be done in five different ways and nobody is 100% sure what's the best way how to do it and also tied with the or linked with the hooks and like how what what you can build with them because you can really build basically anything uh you will struggle with interoperability because
if you can have completely customized hooks with like custom features then you might also need some customized interface to operate those pools because without that you won't be able to guarantee that the pool will work as it should or you know J the experience working with the pool that it will work as it should so for example if you are I know some yield aggregator or asset manager you know right now you have some kind of standard when you are integrating the V3 pool with V4 and the hooks and customized pool you will struggle with that because one pool could have liquidity management another
one could have Dynamic fees another one could have order book on top another one could have combination of multiple Hooks and you know it won't be be that easy to do that and the last thing uh what we believe is that but that eventually all theity will lead to V4 uh because you can build anything on V4 if you want a V2 pool you can have a V2 pool or basically pool that will act as V2 pool even like with the liquid locking hook that we built that that forces you into an infinite range so basically a V2 pool and we just added liquidate incentives on top and if you want a V3 pool I like V4 is
uh V3 on steroids so there's no problem there so why would you go back to the previous versions then you can do everything that you need on V4 and get all the benefits from V4 like the Singleton uh flesh accounting native assets and more generally it will be also interesting how this kind of develops further because pancake is also launching there before algebra has already launched their version of hooks so it will be it's becoming more competitive um but that's it from my side uh if you are interested in reading more about the hooks under the QR code you can find all the
details and or you can just catch up with me after thanks thanks a lot Michael um would you still be available for a question or two if we have any from the audience um any questions perfect first questions about there uh thanks for the talk um do you think that in general uh V4 is a uh a good way to to work on on their like new version due to its uh opportunities so many opportunities that it opens or rather not very good idea because of so many issues like security
related and uix related um yeah so so the question is would you rather say that it's uh good good path or a bit wrong one