Uniswap v4 Exploring New Possibilities I Nico Acosta and Angela Ocando
ETHGlobal·Tue, Dec 9, 2025, 12:00 AM
Join Nico Acosta and Angela Ocando for a workshop titled "Uniswap v4 Exploring New Possibilities", featured at ETHGlobal Buenos Aires 2025! _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇦🇷 *ETHGlobal Buenos Aires* This workshop is specifically for ETHGlobal Buenos Aires, a 3-day hackathon held November 21-23 at the Centro de Convenciones Buenos Aires, bringing together the most skilled web3 developers, designers and product builders from all around the globe for a weekend-long adventure to advance the Ethereum ecosystem! Watch the full ETHGlobal New Delhi 2025 playlist here: https://www.youtube.com/playlist?list=PLXzKMXK2aHh76O7FfAHPJkZcqTIfYpoyf _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *Follow ETHGlobal* X: https://x.com/ETHGlobal Warpcast: https://warpcast.com/ethglobal Website: https://ethglobal.com YouTube: https://www.youtube.com/c/ETHGlobal _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _Are you interested in Ethereum development and entrepreneurship?_ 👉 Sign up for the next ETHGlobal event: https://ethglobal.com/events 🎁 Get exclusive access and perks with ETHGlobal Plus! https://ethglobal.com/plus 📣 Want us to throw an event in your city? Tell us where! https://ethglobal.com/city
Transcript
Thanks for joining. Just to check uh red here speaks English, right? Or understand. Yeah. Okay.
Um my name is Nico. I'm from Monoses. I'm ambassador for UNISO Foundation. I've been working on smart contracts for a couple of years now. I'm working on a product also building on top of uni4 hooks.
So yeah that's why I get engaged and I learn a lot about the the ecosystem. Uh first of all these tracks are presented by unisoft foundation. Unisoft foundation is an organization made to support the unis swap ecosystem h in terms of governance decentralization developer and everything that you already know. So yes to jump in I guess that you already know something about unis swap since v1 is a permissionless protocol made for swapping one so and for another uh it changed a lot over the years. H B1 we used to have like only e2c20s then between introduced all kind of year 20s.
Uh and three introduce um concentrated liquidity. This is like another form of managing liquidity and make it like much more efficient. And the interesting thing that we will be covering today is before this new version that has been live for a couple of months this year. Uh some differences that you will find when trying to build on top of it. So first is a singleton architecture.
This means that all the contracts are everything happens within a single contract. Uh in previous versions we have like one contract per pair of per pool. In this case like everything happens inside one contract. There's an unlimited feier set. So you can choose whatever feier that you want.
You are not limited to the three or four options that you had before. You can choose whatever you want. This is really powerful. like a couple of months ago the must be more part of volume for stable pairs were already on before pools because they could choose like a lower feier. So that's already really powerful.
Um there's dynamic fees. You can also change the fees from the hook. So that's something interesting as well. Uh all tokens are managed internally in some standard that you will see there. So you don't depend on making a lot of transfers for swapping and routing but you deposit tokens.
You make like a lot of swaps internally and you can then withdraw them. That is like so much uh gas efficient. There's flash accounting. This means that you can do a lot of trades and at the end of the trade you will check the deltas the balances and check that everything is fine. So you can also do some kind of similar to flash loans or interesting stuff when routing uh inside the pool manager.
And there's hooks that is the most important and fun thing that we will be covering today. H so just to give you an idea here we have like a V3 or V2 architecture where we had different contracts for making one single trade. In this case there's like 10 external calls for those coding solidity. You know that making external calls is the most expensive thing we can do from our contract. So for routing it's trade throughout four pools in the middle there's like 10 calls to ERC20s and the pairs from the router.
So that's a lot of us and when seeing before you can see that everything happens within one pool. So you in this case you will deposit some ETH get the your CC909 that is kind of this voucher this wrap token that lets you do the trades. you route and do all the trades internally and you withdraw what you want to withdraw at the end of the trade. So this is like so much uh gas efficient. In this case we can see that the similar trade on B3 and on B4 with the same almost gas price is like 10x less gas for our transactions.
So yeah it is like really efficient. Um so what can we do with hooks? Um at a high level hooks let you put your own code within one pool. So you can use one of these 10 uh hooks and you add your code before and after some point in the life cycle of the pool. So you can put your own code before or after you initialize the pool.
You can put some code when somebody adds or removes liquidity. You can do it maybe the most common when you are swapping before and after and donate it is kind of a a tip for for LPS. So this envious to do a lot of things you can like revert trades you can have like a white list and check who is trying to add liquidity or swap and revert the transactions if they're not in the allow list. Um you can modify data. So for example in the swap you get the default calculation of unis swap for the trade.
You can modify that or override your own curve and your own trading logic. Uh so how this works. So first there's like a couple of different options. Um you can have like just one hook contract that you are using for one pool. You can also call in a different architecture your hook contract so that it works for multiple pools but you cannot have more than one hook contract for your pool.
This means that when you are creating a position in a new pool that doesn't exist like before we would identify the address or the which is the pool by the token A token B and the feature now we are adding another thing that is the hook like you can have all those possibilities with infinite hook addresses or none so if you don't use hooks and you create a position it's like B3 but much more efficient because of these guys things that that are new but you can add a hook and customize a lot of of the things. Um yeah so when we when we are routing the trade the pool manager that is the single contract that handles everything uh will check if the hook address if the the pool that you are trying to trade has a hook then it will check the hook address it will know if which of the hook they have implemented. So in this case we will check the before flag. If it's true it will call the hook contract to run the logic. It will return with a call back to the pole manager.
Execute the swap and the same if the after. Obviously you can choose which ones to implement in for example swapping. You can implement like only after only before or both depending on on what's useful for you. Um what else? Like two main resources for building.
So you have the before template that is a ripple that gives you some templates and and base to to build on top of and the other tool that is really powerful is the open sinking unis swap hook library. So just as we have like the contracts with tokens and upgradability and everything that we already use from uni from open sine there's a dedicated unis swap hooks library which has lot of like basic stuff to build on top of and also like some really useful templates that just by coding and adding a couple of lines lets you do like really powerful stuff and we will be looking at it too. So I'm going to skip this and we're going to go back here. Just one a couple of examples to understand better what we can do. Uh for example, if we are working on stables, we could create a hook to incentivize PE stability.
So in this case, we have like a fixed one value or maybe we're quering an oracle to see which is the actual value of the stable coin. uh and we can like make different decisions regarding which is the direction of the hook or which is the current price and the target price. So for example, if like the price now is 1.02 and we want to incentivize the stability, we can modify a couple things to incentivize it going to one and making some other things to in incentivize going like the paying more. In this case, for example, we could change two things.
One is the fees. So with hooks we can modify the fee that is charged to users that meaning the fees that go to LP to the liquidity providers. So if they are going closer to one we can lower the fees so we incentivize those trades and we can change also the the deltas. What are the deltas? Basically amount you put in the amount that you will have to take out or the other way around.
So you can also modify that. So basically how much the user is putting in you can choose how much they will take out. In this case you can use like default unis swap math that is building on the protocol. You can get the default amount and modify it. So let's say that you calculate the base the basic delta that is already brought by the unisoft protocol and you like make it kind of a discount or adding more to that.
So you can build on top of it or you can override it and do your own math curve like in this case the possibilities are endless and you can do a lot of interesting stuff. Uh you could also make like a B2 like uh trading logic between your V4 pool. Um, similar to this, let's say that you are working on memecoins and you don't you want uh only them to go up. You can create like this dual pricing thing where you get like you detect which in which direction the trade is going. So zero for one or one for zero is like direction of the trade.
If it's going up, you can give a better delta or lower fees. If it's going down, you can give like worse deltas and higher fees. So you can play with these things h to make interesting stuff. H another great example is map taxes like you can use priority fee to hear like how much the user is paying for the transaction above the base fee. Uh if you identify the priority fee is very high that high likely is a me attack or a strategy.
You can identify me and h increase the feed. So there's like a revenue sharing between searchers and me and LPS like previously lot of value were to searchers and non to LPS. In this case you can like share the the the destructive value with LPS. Another really powerful thing rehypotheication. This means that you can deposit the the the funds that are deposited for liquidity can be used to be deposited in other stuff.
So after the swap you will deposit all the liquidity in a morpho or any other protocol. Before executing the swap you're withdrawing getting the assets executing the swap and depositing back. This means that LPS will not only gain LP fees like the default uni thing but they will also learn earn from yield from other protocols where it is a positive. So this is also like a really cool thing. And with the open library there's the rehypotheation hook.
I think that I don't know if it's like on the last release but you can find it on the repo h so just overriding these three internal functions you can get rehypigation h so it's like just deposit to this protocol withdraw it and some amounts calculation and it's like a really straightforward implementation and it's like really powerful um resources there's the hacker toolkit for the for the hackathon you can ask for the QRS later because we are kind of rushing with the time. H we will be here on the booth and on telegram so you can reach out to us and is also here and there's like a telegram group for support so happy to chat about that after um and if I have I think three minutes left I'm going to show you quickly okay so key ripples before core is the implementation of the uni protocol um here we'll find the hooks interface. So this is basically what the pool manager will be quering to other contract to our contract that is like the these functions that we've discussing. Important thing you will see that some of these functions give us some information from the hook scope like who is the sender h the pool key that is the identification swap params hook data that is something custom that we can build in to receive information from our router. Um then there is base hook that is like the hook that the contract that we are always inheriting because it has some nice features.
Let me find it here. Okay. So basically we will inherit this base hook that basically what it does is it implements the hook functions with the revert. So we have to inherit and reimplement them if we want to use those hooks. Um and we will be having for example in this case if we want to do some compliance white list thing we assume that we have some other contract with the we have some other contract with the Y list we save the Y list on the contract and when executing a swap like before add liquidity we check if the sender is in the Y list if he isn't we will revert the transaction h otherwise it will continue so this is like just one line and compliance while list built on our hooks.
Uh we can check an NFT collection and if the sender has some amounts uh we can set the fee like zero fee or more fees. Erh we can do some fun thing that if the blog number is even we can charge fees otherwise not just as a as an example to to understand a little bit more. Uh so yeah there's like a lot of things that we can do with this. It's like playing the with the incentives for different stuff. And going back just to wrap up, there are two different tracks.
H one based on stable assets. So working on stable coins or things like that. So we can create the best incentives for our for that kind of assets. And then we have another track for volatile pairs. This means that for other kind of assets.
Uh so there's like a lot of things that we can do for managing liquidity uh getting the best incentives between traders and LPS. That's an interesting thing because there's a lot of hooks that gives a lot of benefit to traders and there's a lot of hooks that give benefits to LPS. I think that the most interesting thing is like getting incentives together for both of them and making it like the the best that brings also like LP profitability and volume. Uh but yeah, there's like a endless possibilities to to wheel with this. Um am I forgetting anything important?
Uh yeah. Yeah, actually yeah, I thought that I quite rushed. I thought we had less time. Uh yes, I thought it was 55, but it's 45. Um yeah, let me show you.
So the other repo is unis swap hooks. This is the library and there's like this bas inherit and implement if you want to do like our own math curve. If we want to manage liquid internally from the hookum the async swaps is the thing that enables us to override math curve and return like our own deltas not based on unis swap math. Uh there's some things for fees like have a dynamic fee, set it based on different stuff. So another interesting example is you could have kind of a volume oracle.
You are saving internally on the hook how much it was traded. If you see that the volume is down, you can lower the fees to incentivize trading. If you see that there's a lot of volume, you can h increase the fees to get like more profitability to LPS. Uh so that's interesting things. So before you had to build oracles on your own like outside the contract and querying all the time to get info using hooks you can enforce like an internal oracle that you know that will receive information and save it in every single trade.
So that's interesting and you can build things uh with that like for example this volume thing I think is quite interesting. Um, and if I can see here, okay, I don't know the status of the last release of open seline, but um, if you go here to this release, that is the last one. I don't know if it's official yet, but it has like some new hooks that are really fun and and interesting. So for example, you have already built in implementation of erh order books, the liquidity penalty, rehypotheication, like the things that were really hard to build. H like all the internal logic is already built for you and you only have to put some things together in order to to use them.
For example, rehypotheication like managing shares and everything was is like really difficult and also risky. In this case, you can inherit open sle implementation and just implement where and how to deposit to withdraw and how much is already deposited and in that way it's already done. There's some other things like anti- sandwich. It's an interesting workar around for avoiding sandwich attacks for users. Um then there was another one I think is the equality penalty to avoid chassis chassing time liquidity attacks.
So something that happen is that when a searcher detects that there's some large trade coming in usually there's some searcher that puts a lot of liquid in that tick to get like the most of the fees. In this case you can create like a penalty system and and like they are not incentivized to do that. So yeah, there's like a lot of interesting and fun things that are already implemented and we just have to code a couple things and we already have like a really interesting and and and powerful hook. Um yeah, I think that is mostly mostly that maybe okay. Yeah, what Angela is saying that we're looking like for the best hook implementation to see that it's like something interesting and powerful.
You can rather like create your own from scratch, use Facebook hook and code it yourself or you can leverage also unis swap library from open sil and create like a lot of stuff and maybe you can like do it much faster and get to more production ready and testing and everything. Okay. And just for testing, there's a also a lot of tools and things to do like well I can share this later because it takes some time but it's like really really easy to test. You can like deploy all the stuff and get it together like in a couple of lines and you start testing and it's like much more uh it's much easier than you would expect. Um yeah, I think that we're close to ready.
Any question here? Yes, we want to share again the telegram QR code here. Yes. Any questions?
Yeah, there's no mic, I think. Yeah. So in that case you you will create your hook contract and then initialize a pool with token A token B the fifth year of is dynamic and the hook address but the liquidity will be managed only for that pool for those tokens. So yeah you will have to bring and attract liquidity to your own pool implementing that hook if that's a question or Yeah, like I think that in in main production, there's like a lot of things about incentives and to really prove that the profitability for LPS is higher. Like if you just implement hypothetication, there's a lot of incentives for liquidity providers to earn LP fees plus a or lending or whatever yield from other sources.
So I guess that is like great incentives for traders to get volumes to get more profitability. H but yes, you will be competing with all the other like vanilla pools with no hooks. Yeah. Yeah. I know if it's if it's like a certain threshold, but yes, I think it will take some time, but it's it's worth trying.
Another question. Okay. Well, we will be around and at the booth, so happy to to chat and whatever. Thank you.
Automatic transcript — names and jargon may be misspelled.