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

Loading player…

Uniswap v4 on Unichain Exploring New Possibilities I suacepoint and Angela Ocando

ETHGlobalThu, Oct 9, 2025, 12:00 AM

This talk, led by Sauce Point, a Uniswap Foundation protocol engineer, introduces Uniswap v4 on Unichain, highlighting its key innovations and developer opportunities. Uniswap v4 features a singleton architecture for enhanced gas efficiency, continuous and dynamic fee spectrum, ERC6909 internal claims tokens, flash accounting, and most notably, programmable hooks. Hooks allow developers to customize pool behavior, enabling programmable liquidity and supporting new asset classes, dynamic fees, liquidity management, and public goods like oracles and advanced order types. The session categorizes hooks into liquidity profitability, liquidity depth, asset class customization, and public goods, providing examples such as dynamic fees, limit orders, KYC compliance, and volatility oracles. Sauce demonstrates live coding with the v4 template, showing how to build and test hooks using Solidity, and emphasizes the importance of testing. Resources like the hook directory, documentation, and Discord are shared for further support. The session concludes with a Q&A on building hooks for various asset classes and optimizing pools for both liquidity providers and swappers. 00:00 Introduction 00:26 Overview & Speaker Introduction 01:46 Uniswap v4 Metrics & Adoption 02:36 Uniswap v4 vs v3: Key Differences 03:43 Singleton Architecture & Gas Efficiency 04:06 Continuous & Dynamic Fees 04:50 ERC6909, Flash Accounting, and Hooks 05:39 Hooks Overview & Programmable Liquidity 06:54 Types of Hooks: Liquidity Profitability 08:09 Types of Hooks: Liquidity Depth 09:20 Types of Hooks: Asset Class Customization 10:39 Types of Hooks: Public Goods 11:47 Resources & Getting Involved 12:36 Live Coding: Building a Hook 13:36 Dynamic Fees & Custom Logic in Hooks 14:43 After Swap Logic & Monetization 15:38 Liquidity Hooks & Penalties 17:23 Testing Hooks with V4 Template 19:05 Deployment Scripts & Chain Configuration 20:28 Custom Pricing Algorithms in Hooks 22:02 Q&A: Asset Class Hooks & Pool Optimization 24:07 Modifying Liquidity & Flash Accounting 24:35 Closing Remarks _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 🇺🇸 *ETHGlobal New York* This workshop is specifically for ETHGlobal New York, a 3-day hackathon held August 15-17, 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 York 2025 playlist here: https://www.youtube.com/playlist?list=PLXzKMXK2aHh4Xze0ZeSWCSGsw25clPpvZ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ ✅ *Follow Uniswap* X: https://x.com/Uniswap ✅ *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] I guess before I start, I know a couple people were like looking for teammates. So, if you guys are thinking or if you're thinking about building on uh Uniswap and looking for a teammate, if you guys want to like raise your hands if you're looking for a teammate, then you guys can like look around and see.

Anybody want some teammates? Okay, cool. Um, cool. Yeah, thanks for coming to my talk. It's just going to be like a brief intro on V4 and then with some live coding, we'll kind of just jump into it.

Uh, yeah. So, we'll talk about like the differences between V3 and V4. I think it's really helpful for understanding like what's possible in in V4. Um, things that might have been possible in V3 but weren't super viable are now like obviously very viable in V4. Um, we're going to have uh talk about like the mental models, like the types of hooks that you can build, kind of help you guys narrow down and like scope what, you know, projects you guys could work on.

And then at the very end, I'm just going to do like a live coding, just kind of walk through like what a hook looks like, um, ways, you know, what these parameters mean, you know, what you can do reasonably inside a hook. So, uh, yeah, I go by Sauce. I'm Uniswap Foundation's protocol engineer. um one of the many great core contributors to unis swap v4. I worked on the pool manager.

I know the position manager like the back of my hand. I'm the maintainer of v4 template and then now that v4 is done people ask me kind of like what do I do? Uh and so it's a mix of like special projects uh devril developer grants and just anything kind of adjacent to to v4 and uh technical stuff. So you can find me on Twitter, GitHub and Telegram at Sauce Point. Um, cool.

Before we get started, I want to, you know, briefly just touch on the the fund metrics of V4. Uh, we recently crossed a billion dollars in TVL. There's been almost 3,000 hooks initialized and we do roughly like almost $700 million in volume a day. And this is just on V4. Um, you know, V3, V2 continues to still get a lot of traction.

Uh, but yeah, V4 is kind of ticking up. One cool stat I like to call out is like 65% of the volume on V4 is happening on L2s predominantly uni chain and and base as expected. Um so yeah good times. Uh so for the people that are new to the room uh you know unis swap v4 like what is it? Um it's very similar to v3.

A lot of the math and the benefits that you get from unis swap v3 carry over to v4. The main big difference is there's two philosophical uh design principles behind V4 and one is uh gas efficiency making it more efficient to do things and making it more expressive for developers. And so on the left you see V3 uh every pool was its own contract. Every token or every pool would you know maintain its own tokens and then uh hopping between uh pools. So if you wanted to trade ETH into D, you'd maybe touch like I guess in this diagram four different pools.

Um, you know, facilitating transfers between each contract. In V4, it's one contract. All the state lives in one singular contract. It holds all of the token balances. And with some really nice advancements, you can kind of really reduce uh some of the gas complexities of of multihop swap.

And so you can kind of see um these are all pools. All the tokens live in this one big contract. And then we have like hooks which are these like little modules or plugins that you can think of that sort of customize the behavior of a pool. Um more concretely like what is v4 like what's different? Uh yeah so what I talked about was the uh singleton architecture.

So it's one contract that holds everything. This is goes leans into like the gas efficiency principle of designing v4. Uh one actually really really big feature that a lot of developers rely on is a continuous fee spectrum. So on V3 you're limited to four different fees and in V4 you can go anywhere from 0% micro fractions of a BIP all the way up to 100%. We've seen a couple like memecoin pools launch at like 2% that actually do like quite well and then because of this continuous fee spectrum we also said like you know let's add dynamic fees and dynamic fees let developers sort of customize you know what fee to charge.

It's not opinionated by the protocol. You can increase it, you can decrease it. Um, you can change it every transaction if you want to. You can change it like once a week. Um, so yeah, another big feature in V4 that was not available in V3.

Uh, ERC6909. I won't really touch too much on this, but it's like internal claims tokens. Again, just reduces a lot of like the gas complexity of uh calling out to ERC20s. Uh, we have flash accounting. Um, essentially this relates back to this design where you can kind of uh maintain intermediate balances as you're like hopping through multiple pools.

And what that does is it allows you to string together a bunch of operations while reducing the token transfer. So you can, you know, swap and use the outputs of your swap to create liquidity, right? And you're actually not swapping, taking out the token, and putting it back in, right? you're just kind of doing it all in one atomic uh operation. Again, this leans into gas efficiency.

And then lastly, we have hooks, right? Uh you can attach arbitrary logic and modify the behaviors of the pool. Um again, into more developer flexibility, developer expression. Uh quickly on hooks overview, it's kind of what you would expect. Uh so during the swap process, we check, hey, does this pool have a hook?

Um does should we call out to before swap? If so, we call out to an external contract, run arbitrary logic, and then we come back to the core protocol, facilitate the the V3 math. Uh similar with after swap. And so hooks are external contracts, right? They live outside the pool, but they're attached to pools.

And what you can do with a hook is really just modify the behaviors of it, offering like what we call like programmable liquidity. Uh, every pool has at most one hook contract, but one hook contract can work on multiple pools. So, if you build a hook for ETH USDC, of course, it works for ETH tether or ETH die. Um, there are 14 functions available. You can mix and match.

You don't have to use all 14. You can pick and choose. You can use one, you can use two. Um, and so yeah, that's V4 in a nutshell. And so just diving down into like the types of hooks that we've seen and how do we like categorize and how do we think about uh what's possible.

We coincidentally have four of them. Uh the first one I call liquidity profitability. So it's hooks that you know provide higher returns for uh the liquidity providers for participants. And so what we can think about like how do we actually improve liquidity or uh profitability? Um one thing is dynamic fees obviously like just charge more money.

So you know there's more volume or more just fee revenue directly paying uh liquidity providers. Uh there's this term that we use called rehypothecation where can we take liquidity in the pool and make it productive through other services like lending? Can you take liquidity from the pool and deposit it into a lending market? Again you know increasing the returns for uh liquidity providers. Um does your protocol have auctions related to it?

Can you can you you know add an auction layer and use the auction proceeds to distribute value back to uh liquidity providers? Um and so yeah that's liquidity profitability. Uh liquidity depth is another type of hook. So these are hooks designed to you know in increase participation support larger swap sizes. Um and so you know can you design liquidity incentives that are sustainable and long duration for people to participate in liquidity provisioning you know making the pools deeper being able to support high higher swap sizes uh just in time um liquidity.

So um this is kind of how Oiler works. Oiler swap it borrows money just in time to create the outputs of a swap. And so what we've seen with Oiler Swap is like trade sizes of like three four million dollars. Um limit order hooks are technically increasing the liquidity depth, right? There's more capital for people to trade against.

And so adding attaching limit orders to your hook um can yeah support larger trade sizes. Uh hooks that manage liquidity in some shape or form. So like you know actively managing liquidity, concentrating liquidity um you can think of as liquidity depth. Um the our third category asset class this is probably like the biggest class of hooks that are possible and it's really trying to customize the pool to support like the tokconomics or the behaviors of the token right not every ERC20 behaves the same. Uh RWAS have compliance requirements.

So it's like how do we add KYC to a pool? um liquid staking tokens acrue value and so how do you design a pool for a token that's perpetually acrewing value? Um maybe there's a custom curve that you could do a different pricing algorithm. Uh maybe you can manage liquidity in a way that you know shifts the liquidity as the price is increasing. Uh rebasing tokens behave very weirdly and so you know can you wrap and unwrap these rebasing tokens?

uh governance tokens um you know designing a pool where you know you can provide liquidity but still maintain voting rights um to participate in governance. Uh memecoins are yeah another big asset class and so how do you optimize volatility? Um how do you make it where it's exciting to trade but people don't lose their shirt right? Another c uh asset class that I don't have on this list is like prediction tokens. Prediction tokens are very interesting in the sense that there's they trade from zero to $1.

There's an expiration time and so like you know as you approach expiry how does the behaviors of the pool change right? Um, our last category of hooks is what I call public goods. It's kind of the catch-all bucket. Um, trading order types. You can think of benefiting swappers.

So, limit order, TWWAM, which is kind of like DCA. Uh, maybe adding volume based discounts to trading. You can think of as a public good. Uh, priority cancels. This is kind of like a research topic right now.

And priority cancels are this idea of can we ensure that liquidity operations happen before swapping happens. So like can liquidity providers remove their liquidity before somebody trades against it. Uh oracles it's a very you know straightforward. So how do you design oracles to be manipulation resistant? Um outside of price oracles we could design you know volume based oracles and maybe your lending protocol uh wants to parameterize something based on on volume.

Uh, and then lastly, volatility oracles. Um, and those are the four types of hooks. And so I know some of you guys have been taking pictures. So there's resources to get involved. Uh, we have this hook directory which is like community built hooks.

And so you guys can take a look at what's been built out there so far. It's a pretty good re uh resource. There's a lot of stuff that's been built. Um, V4 template, which I'm going to like dive into. Uh it's a great starter kit.

It sets up your dependencies, has like a template hook, has your tests set up, scripts to deploy. Um and then if you need to get a hold of us, our Discord is also a great place for technical questions. If you guys um have any sort of issues with building or have questions, yeah, Discord's a great place. Uh more resources, of course, we have documentation on it, uh V4 template, and then you also have me as a resource as well. Um, cool.

Um, so I guess yeah, now I'm just going to jump into live coding and we'll see where it what happens. Um, cool. Can you guys see that? Okay. Uh, yeah.

So, this is V4 template. Um, it's just cloned down. And this is what a hook looks like. Um, like I said, it's a contract. uh you can kind of designate the behaviors of the hook.

So like before swap and essentially yeah it's just valid like a contract and any valid solidity works here. Um you could do really like bizarre things if you wanted to like uh deposit in compound for whatever reason. Uh more practical applications are so this example is counting. So every time somebody trades on this um pool, you know what if we did like points calculations. So like if this mapping was something different um uh let's just assume message sender is the user, right?

And you know you could like increase points and track points for users. Um other things that you might want to do is like uh dynamic fees. And so if you have a function And you know the function looks at the pool key maybe looks at uh the swap parameters. So like maybe for bigger swaps you want a discounted fee. Um we could also include like time here right um I won't implement this function itself but you can think of just like an abstract function where hey given a bunch of inputs return a fee a value right and as you can see with copilot it's kind of suggesting that hey in before swap you can run this logic to calculate your fee and then you return it back to the core protocol the core protocol will then read this value and apply it uh to the swapper Right.

Um so that's some things you could do. Uh and after swap um you get the results of the swap. So this balance delta here. So after a swap happens, you could uh maybe charge an additional tax. Um that's possible to do in hooks.

So like charging an additional tax. I'm just going to kind of like pseudo code this, but like it looks like pool manager take,

you know, something like this, right? Uh so inside after swap based on the results of the swap, um you could then charge an additional tax or monetization. Uh you could also do things like uh donating back to the pool to reward liquidity providers. Um yeah, that's also possible. Uh there's also the liquidity hooks.

Um there's four of them. You so before you add liquidity, you could run something. Before you remove liquidity, you can also uh do something. There's also after liquidity. So after add uh one thing that we've seen anecdotically is like you can charge penalties.

So, uh you know before you add liquidity or maybe it makes sense to do it after, right? Um, if you had like some sort of mapping like uh creation time uh position ID or something like that like this is just all pseudo code but like and then so after you create a position you record its time and then whenever the position's getting removed you could do like something like this. Oops. And then you can compare uh you can you can compare the difference between like how long the positions lasted and if the position has only lasted for like 30 seconds or something like that. you could then like take their fees you know by calling pool manager take right um so yeah there's a lot you can do here um again any valid solidity works there's a bunch of uh functions too on the pool manager for you know swapping um donating modifying liquidity uh like a position or a hook could create positions in before swap and then after swap close the position if it wanted to.

Um I'll quickly dive into uh the tests and so we also have tests set up in uh V4 template. it, you know, deploys the pool manager for you, creates mock tokens, deploys the hook, uh, creates the pool with the starting price, creates full full range liquidity, and then you can kind of see in the tests that we're like running a test swap on it, and we're checking that, hey, the the state has changed on the hook. You can also observe the swap amounts. And I think if you guys are interested in building this weekend, I would highly highly recommend uh use tests to like validate your idea. Wouldn't really try using like test nets because like the reverts aren't super like helpful.

And so yeah, testing will be a really really nice resource. Um

yeah, this is a foundry repo. It's a foundry template. Are you a hard hat guy? Sorry. is like

just running instead of test running like scripts that will do like sequence and then the result

uh yeah you could fork my whole thing with testing is whenever it reverts you kind of see which function call reverted whereas if you go on like ether scan it's just like the transaction reverted and you're like where? Um

but yeah. Yeah, you could definitely use forking. We also have scripts in here too if that's helpful. So like deploying a hook. Um you can run these against Anvil, you can run these against Sapoleia, you can run them against mainet if you're feeling crazy.

Um I guess one thing I will mention that I believe um I believe the tests are kind of set up uh intuitively where or maybe it's the scripts where it will automatically like determine your chain ID and then look up the pool manager address for you so you don't have to like configure a bunch of stuff. Um maybe it's in here. Yeah. So, in the scripts, uh, you can see that we're like looking up all the pool manager addresses on all the chains and stuff. So,

cool.

Yeah.

So, you mentioned earlier

Yeah, it's kind of complicated. Um, if you're just starting, it's really involved. But the way it works, the core idea behind it is the hook would uh take the input. Uh, so it looks something like this. And then based on this return, uh, Sorry.

So depending on how you return this data here, um it's kind of confusing with the signage. Sometimes you use a negative, sometimes you use a positive, but there's a way to configure the return such that you signal to the pool manager saying that hey, I took all of the input. There's no input remaining for the V3 swap math. And so with hooks, you can kind of what we describe as like eject the V3 swap math. And so you take all the users input um you calculate your output.

Um, right. And then you would provide it back to uh this, right? And then this output that you give to the pool manager, the pool manager will then give it to the user. And so really like the meat and the potatoes comes into like this function here. I just tot like hand hand waved it.

But yeah, you can kind of like roll your own like pricing algorithm. If you want to like read the Binance price, if you want to read chain link price, uh if you have like some really advanced Yeah. pricing algorithm, it's kind of just like all in this function. And this is roughly how custom curves work. And then yeah, it's in our documentation.

I think there's some examples floating around. So cool. Were there any other questions or Yeah, in the back. What is your wish?

What is my wish? Um, I would say my wish and I think the path of least resistance is like building hooks for for asset classes like how I talked about it in earlier there's like three types of hooks. So like designing hooks um that are like really good for I don't know I guess the I'm trying to think of like the most exciting like ERC20s out there. I guess there's yeah um RWAs and stable coins. There's prediction tokens.

Maybe like pendle yield tokens are also like really interesting and thinking about how to get those into into unis swap. Um

have

Yeah. Yeah. Yeah. Yeah. Or like how do you design a pool such that it like behaves better for both liquidity providers and swappers, right?

Yeah. Yeah. Yeah.

Yeah. or like a standard pool, you're more likely to like lose money or something like that, right? Like if you LP with a liquid staking token, right, that's acrewing in value over time. And so be because the pool price doesn't account for it, you're more likely to sell it at like a stale price. You're going to sell it below, you're going to sell it at a discount because it's perpetually like increasing in value.

Uh yeah, that's one way of doing it. There's some theories around like maybe modifying the liquidity. So like um we have a function called like modify liquidity. So, it' be like uh you would like close a position or something like that and then like reopen it. Um something like this.

It's like kind of like pseudo code, but you can you can kind of get the idea. So, you' like close the position, adjust its range, and then reopen it. And the cool thing about flash accounting is you don't actually have to withdraw the tokens here. Um you would only need to pay the differences. Do you have any?

Uh, I don't, but it might be in the Atrium database. Yeah, I do have to wrap up here. Um, so getting cut off, but if you guys want to find me, I'll be floating around. Uh, so [Music]

Automatic transcript — names and jargon may be misspelled.