New Ethereum talks, every Monday. The week's conference uploads by event, in your inbox.

Loading player…

Uniswap v4 Exoloring New Possibilities I Angela Ocando and Dayitva Goel

ETHGlobalSun, Nov 9, 2025, 12:00 AM

Angela Ocando and Dayitva Goel (Uniswap Foundation) introduce Uniswap v4, highlighting a major architectural shift to a singleton pool contract with flash accounting and a continuous fee spectrum. The headline feature is Hooks—external smart contracts that can run before/after swaps, liquidity adds/removals, donations, fee updates, etc., letting developers program custom pool behavior (risk controls, pricing, access rules) while keeping gas costs low. Compared to v3’s multi-contract routing, v4’s singleton reduces on-chain hops and enables more seamless, gas-efficient trading and liquidity operations. They then walk through problem statements to inspire hackathon builds: TVAP execution and stable-to-stable efficiency for large trades; Pendle-style time-decay AMMs; World ID/KYC-gated pools; lottery/no-loss pools; smart borrow via re-hypothecation of out-of-range liquidity; and RWA issuance hooks with compliance checks. The session closes with a live demo of the v4 Hook Template (Foundry): scaffolding a basic hook, tests, deploying mock tokens, initializing a v4 pool (currency0/1, fee, tick spacing, hook address), adding liquidity, and performing a swap—showing how to flip specific hook callbacks on/off and verify they trigger correctly. 00:02 – Introduction and overview of Hooks in Uniswap v4 01:00 – About the Uniswap Foundation and its mission 01:31 – How the Uniswap protocol works and its evolution 02:21 – Key upgrades from v3 to v4 and ERC-20 support 02:48 – Continuous fee spectrum, singleton architecture, and flash accounting 04:18 – Gas efficiency and improved trading experience 04:48 – How Hooks work and their role in customizing liquidity behavior 06:14 – Hackathon problem statements and innovation ideas 06:31 – Stablecoin efficiency for large-scale swaps 07:07 – Time-Weighted Average Price (TVAP) execution hook 07:45 – Pendle-style AMM with time-decaying assets 08:09 – World ID verified pools and KYC-based access 08:41 – Lottery pools with social reward systems 09:17 – Smart borrowing and liquidity re-hypothecation 09:36 – Real-world asset issuance and compliance hooks 09:56 – L2 hooks for small and medium trade optimization 10:30 – Developer resources and hacker toolkit overview 11:26 – Using the V4 Hook Template for development 13:33 – Forking and deploying your first hook contract 14:54 – Creating mock tokens and setting parameters 15:15 – Deploying a pool and adding liquidity 16:32 – Performing and verifying swaps 17:20 – Closing remarks and developer invitation _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇮🇳 *ETHGlobal New Delhi* This workshop is specifically for ETHGlobal New Delhi, a 3-day hackathon held September 19-21 at the India International Convention & Expo Centre, 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=PLXzKMXK2aHh7zCFW3hBqatZ18rQaYeEJL _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *Follow Uniswap* X: https://x.com/UniswapFND ✅ *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

[Music] Now it is possible to fully customize your DeFi experience from the swap cycle. meaning before and after the swap, you can add some sort of like logic that allows you to build any other possibilities that it wasn't uh possible before from real world assets or even improving the liquidity provider experience, but I'm going to be tougher during the weekend for sure. Um we call that hooks and these are some of like sort of a scripts that you can add now to your liquidity pools. So throughout this call we are going to or throughout this talk we are going to guide you over the unis swap v4 protocol along with all of the the features and a v4 template that after that it's going to allow you to build and uh deploy your first uh hook for short. Um let me introduce you first the unisot foundation.

My name is Angelando and along with my colleague Divided um we work at the UNISO foundation and it's basically uh supports the growth decentralization and sustainability of the UNISOP community and through all grants and other some sort of like incentive and initiatives. We support five key pillars from protocol and innovation developers we are here for sure governance research and security team. So now let's a little bit of overview around the unis swap protocol that it's basically a peer-to-peer system that allows you to swap and like trade a pair to another. Let's say you want to trade ETH for USDC. So, you can do that in the unis swap protocol in a decentralized ways throughout liquidity pools.

Basically, a liquidity pool it is a smart contract that connects liquidity providers on a side and traders on the other. So think about the D5 projects that you're looking to build. If any swap needed all provider liquidity on it, you can just integrate the protocol. Uh first launched back in like 2018, the unis swap B1 version. Now we are in the B4 uh version.

Probably you've been interacting with like some of them in the in the in the history. It's uh basically from the B3 version. If we go straight uh you can now uh support ERC20 to ERC20 token. So e any token out there EC20 you can do it. Um and then the price curve it is a concentrated liquidity one meaning if you are liquidity provider you can go over a tick and say I want to add my liquidity on from 2,000 the price to 3,000 if price or whatever.

So that's important. And then you used to have some sort of like fixed uh fees from 0.00 uh 5% to 1% but now before allows you to uh define the continuous fee spectrum and dynamic fees meaning you as a developer define the rules and you can say hey I want to define dynamic fees depending on the volatility of the market. So we are in a bull market but a bare one. So you want to adjust all of this information but also the B4 not just includes that but rather the singleton architecture any of the transactions and everything happens in one uh contract all the pools all the tokens that's from one side for gas efficiency but also in the end you can build a better experience out there for your users we also have another some sort of like features such as the ERC6 uh 909 and also the flash accounting that uh from internal tokens to arbitrarian connections or operations sorry um it's basically the way that now as everything is happening in the same contract you can build a seamless training experience trading experience out there and as I mentioned at the beginning of the talk if you remember I said something like now you can customize your logic in the sub cycle before and after the swap we call that hooks as mentioned arbitrary logic attached to the life cycle operation so now everything is focused on gas efficiency but also developer expression meaning you guys define the rules for completely.

Um so yeah this is like a visual example of how it used to work at B3 version of the unis swap protocol and now how is working in the in the B41. So back in the day if you wanted to trade ETH for D let's say like that you had to go from ETH to USDC and then USDC to die right now everything happens in just one contract along with the features that we have as I mentioned the single tone one and the flash accounting and so on. So yeah, you can see here deploying on mainet um how the price of the gas goes from like uh almost 60 bucks to uh $4. And yeah, just a bit of the hooks overview. As I mentioned, this is important because it's basically part of our bounty and like our challenge uh for you guys during this hackathon which is build hooks out there deploying in any chains but we want you to challenge and build one of these external contracts that basically now modify the pool behavior.

Hooks don't just move assets but define the liquidity behavior out there. Important note in here only one hook per pool but then one hook can serve any uh other pools out there. We have 14 hook functions. The eida is going to be uh at that deal mentioning that before and after the swap you can add remove liquidity or after uh add remove donations update fees and so on. But basically what happens on the swap cycle is that when the start uh the swap starts you can check before the system checks before swap and then under uh it's going to validate if you added any some sort of logic or not and return that if not just goes over the execution of the swap and then it's going to check again but after the flag if you added any some sort of like custom logic or note before ending the swag for sure.

Uh so at this point I think we're ready to go over some problem statements to for you to visualize better um all of the ideas. So go ahead.

So I'll be going over some problem statements that we have designed for you to give you some ideas to hack over this weekend. You're not limited to these problem statements. Of course you're feel free to use anything else but this is to give you some inspiration. The first one is the stable stable efficiency at scale. So the idea here is to design a hook that targets the stable coin pairs on ETH mainet with trade sizes over half a million dollars.

Um the important thing to consider here is of course the mainet gas costs which can be really expensive. So you need to think about how do you design this hook and how does this hook compete with other dexes in this market. Uh one idea that you could possibly do this with is by splitting this trade over time so that you reduce the price impact and not just give them one price execution. The second is the TVAP execution hook. It's closely related to the first one that I just talked about.

You need to design a hook that enables Steve app which is the time weighted average price. Um again you can split the order into multiple times and then you can minimize slippage and give a better price execution to the user. Um again you can integrate this with other sponsors like 1 in and the limiter orders or even with unis swap's own smart order router. Next is the pendal style emm rebuild. For people who don't know what Pendle is, it's it has a time decaying emm and it splits an eelbearing asset into a principal token and an and a eel token and it has a really interesting way of pricing these assets which is not usually possible.

But with hooks now you can enable assets that were previously not possible before. So could you in fact design the whole time DKM AMM by Pendle directly as a V4 hook. Next is the world ID verified pools. So, Coinbase already uses Uniswap V4 for its own verified pools. So, it's it offers KYC and AMM institutionalized standard pools to users so that they're not interacting with pools that do not meet meet the standards.

So, you can use world ID and build a world ID mini app that only allows verified users to interact with certain pools. Um, again, this is to improve and reduce the civil resistance and improve the UX and the compliance in D5. Next is lottery pools with social. So pull together is a no- loss lottery which allows you to redistribute the eel uh and h redistribute the eel to the stakers and could you in fact design this entire thing as a v4 hook and possibly use this as a hook enabled world mini app as well. So what you can think is instead of redistributing the LP e to the users itself, you store it and after a certain time period you give it to one person or depending on the price uh the price pools that you might have.

You could also incorporate social rewards, world ID and gas abstraction features right into this. Next is a smart borrow hook. Another superpower of hooks is the rehypothetication of liquidity. Which means that any liquidity that is not currently active in range, you can just pull that out of the uh out of the pool and provide it on lending platforms like a or Moro or compound and give them a better result to the LPS. So you could implement smart borrowing, leverage automation and even conditional loan logic with these V4 hooks.

Next is primary RW issuance hooks. Again, because hooks enable assets that were previously not possible, you can now have RWS on V4 as well. So, could you design a hook that supports these assets? Also, you need to integrate certain KYC and AML check. So, again, using some of the previous ideas and some ERC 6343 or other institutional standards that you might know of.

The next two ideas are a bit complicated, but again, we are looking for open innovation in these cases. You need to design a hook for ETH USDC swap in the less than 5,000 range on L2s. again. So, Uniswap already does a really good job of giving a good price execution for these swaps, but could you think of ideas that take it to the next level? Can you guarantee best price execution and even compete with aggregators with such a hook?

The next idea is of course to take this a step further, which is the mediumsiz trades of 10K to 100K. Um, could you recapture mess for LPS, create an incentive mechanism that boosts volume or even liquidity depth for such pairs? So, these were all the ideas we had. Again, feel free to check out other ideas that we have and you can build anything literally. Coming over to the resources that we have, the first one is the hook directory.

Atrium Academy is the learning arm of UF and it conducts the unis swap hick incubator which has a hookathon at the end. The cohort 7 is going to begin almost in October. And the hook directory has all of the projects that have been built previously in these hookathons along with all of their open source front end and backend code. So feel free to check that out for your own inspiration and seeing how hooks have come along. Next is the UF hacker toolkit.

This is the one-stop shop place that holds everything that you might need uh ranging from the ideas that I've just discussed right now, the judging criteria that we have, all of the doc documentation and the resources that we have as well. So yeah, scan the QR code and get all of that at one place. Next, of course, coming along to the B4 template which is the bulk of this talk. Now, this is a template that we have designed for you to get started with V4 hook development as soon as possible. This has all of the dependencies, some scripts to help you out, some test scripts, and our basic hook contract to make sure that you don't have any problems with V4 hook development.

I'm going to be giving a small demo of how this works. I've already cloned this repo on my local machine and the readme of course mentions the steps to get started with this. You this is a foundry based repo. So you just need to do forge install which I've already done and you can do a forge test to see that everything's work perfectly and yes it does. So it means that the repo has been set up correctly.

The main hook contract is in the src directory in the counter and I can just do this. This is a very basic hook contract. You define a hook a hook contract again is basically a smart contract which imports as inherited with the base hook. It has the 14 hook functions that Angela just talked about which is the before initialize after initialize all of the 14 ones with swaps removing ad liquidity and donations as well. And you need to set them to true the ones that you're going to be using.

In this case I have set the before swap after swap and then before add liquidity and before remove liquidity as four. So I'm using four hook functions in this. And the hook functions are also simple. You just define what the before swap does and it is a mapping that I'm just incrementing by one. So anytime a swap takes place a before swap and after swap should turn into one.

Anytime I add liquidity this should increment the counter. Anytime I remove the liquidity this should increment by one. And this is what the test script actually essentially did as well. So in the test you can see counter.t.

soul. This is a test script that you can use. We set up the entire pool. We add liquidity to that pool and then we write some test functions. So in this test functions we check that the before add liquidity was one because when we initialize a pool and add liquidity that should have been called but all of the rest should have been zero and after you uh after you do the swap the before swap and after swap should both turn into one.

Uh because in a life in a swap life cycle both of them are called. Same with the test liquidity hooks anytime I remove the liquidity both add before add and after remove should be called. Uh the tests I already showed you how to run. Um you can do this on a fork of a mainet fork of a test net as well. So I'm going to be using uni chain sepoleia for this.

I'm using anvil and I've already set my RPC URL and this should start an a fork of uni chain seapia over here and yes it's already done. So I can go to another one and I can just deploy the hook that I've just shown you the counter soul. So I would call forge and deploy hook. What I'm using is a private key from anvil. Again uh it's a public private key and again I'm broadcasting it to the local folk that I have and the script ran successfully.

Everything was successful and we got the hook address over here. We can just take this hook address, go to the base script and change it over here. Again, the address did not really change because this is all deterministic and I've already done this before. But these are the three things that you might need to change. After you have deployed your hook, you want to deploy a pool and add liquidity to it.

But before that, you would want to create some tokens. So I have a custom script called as create tokens. This would just create new tokens for me. zero. This should create two two mock tokens for me.

And it does. It gives me token zero address token one address. And it also mints me a certain number of tokens to my particular address. Again, those addresses are already the same, so I don't need to change them. But essentially, you would just copy paste over here.

After you have created those tokens, now it's the time to deploy a pool. So let's deploy a pool. Now, so this script creates a pool and adds liquidity directly in one script. I can show you what's happening in this case as well. So a pool in V4 is identified by five parameters which is the currency zero, currency one, fee which is of course can change now instead of the three tiers that we had earlier, tick spacing and of course the hook contract which is the most important.

uh in this case you define the pool key then you set what the starting price should be using the current tick you specify what the upper tick and lower tick for your own particular liquidity that you're adding should be you do this all of these actions again you don't need to understand this all a lot because it's already in the script but of course feel free to come to us if you have any doubts we do the token approvals and then we just multi call with this and if everything was successful yes so a pool was deployed and the liquidity was added as well final step let's finally do a swap on So I can just call the swap script and I can show you what the swap script is as well. A swap script again you define the pool key through the five parameters and you uh approve both the tokens. You don't need to approve both the tokens. You only need to approve the token that you are going to be inputting in. But uh this is just for testing.

You specify on this swap router there's a function called as swap exact tokens for tokens. You specify the amount in the amount out that you want. This is what specifies what the slippage is that you're willing to encounter. I've set it as zero which is bad practice but this is again testing. You should in production always specify the exact amount out that you are willing to get.

Then 0 to 0 for one which specifies if I'm inputting token zero for one or getting token one for token zero. pool key hook data which is uh the data for the hook in this case it's all zero and the receiver which is my address with a deadline and if everything was successful yes uh the swap did take place correctly and you can just do a swap so everything is there in this v4 template right from setting up the pool to doing all of the swap and yeah happy developing on this yeah thank you so much [Music]

Automatic transcript — names and jargon may be misspelled.