Epicenter - Learn about Crypto, Blockchain, Ethereum, Bitcoin and Distributed Technologies - Balancer: Custom AMMs and Liquidity Solutions - Fernando Martinelli

Episode Date: January 31, 2025

While AMMs (automated market makers) represent a DeFi innovation in themselves, research and experimentation have pushed the possibilities well beyond the limitations of the classic x*y=k constant pro...duct formula originally used by LPs. One of the main innovators in this field remains Balancer - from multi-token pools with different weights replicating TradFi indices, to dynamic ratios that can be changed under certain conditions preventing further imbalances, Balancer set in place user protection measures. With the recent release of Balancer V3, developers get more freedom to experiment with AMMs, introducing features such as hooks that enable limitless pool customisation, boosted pools that combine LP fees with yield farming from money markets, and many more.Topics covered in this episode:Balancer’s inceptionThe evolution of AMMsBalancer vs. other AMM competitorsFungible vs. non-fungible liquidityBalancer v3Boosted liquidity poolsDevEx and hooks in Balancer v3Preventing stablecoin depegsMEV mitigation & CoW AMMScaling to L2sGyroscope & QuantAMMBalancer’s B2C & B2B solutionsEpisode links:Fernando Martinelli on XBalancer on XSponsors:Gnosis: Gnosis builds decentralized infrastructure for the Ethereum ecosystem, since 2015. This year marks the launch of Gnosis Pay— the world's first Decentralized Payment Network. Get started today at - gnosis.ioChorus One: Chorus One is one of the largest node operators worldwide, supporting more than 100,000 delegators, across 45 networks. The recently launched OPUS allows staking up to 8,000 ETH in a single transaction. Enjoy the highest yields and institutional grade security at - chorus.oneThis episode is hosted by Friederike Ernst.

Transcript
Discussion (0)
Starting point is 00:00:00 AMMs didn't need to be only the simple version of X times Y equals K, which implies that the pool always has like the same amount of value in both tokens and discovered that it's possible to have any number of tokens with any weights that you want, like pretty similar to what an index fund or an ETF would look like. And that was Ballacer. Valacer VALISER V-V-1. We launched in 2020. And yeah, since then we went more from an end-user-user-focused. protocol to a developer-focused protocol where people can build their own AMM innovations on top of Ballaster. So we went in that direction with Balancer V2. There are people who say like AMMs are what they are now and there's not much to do. But then we see a lot of interesting things like priority fee mechanisms. Balance V3 is a bet that this is going to keep happening and we want to be this platform for
Starting point is 00:00:56 people to try new things around AMM design. Welcome to Apple Center, the show which talks about the technologies, projects, and people driving decentralization in the blockchain revolution. I'm Frederica Ernst, and today I'm speaking with Fernando Martinelli, the co-founder of Balancer Protocol. Before I speak with Fernando, let me tell you about our sponsors this week, though. If you're looking to stake your crypto with confidence, look no further than course one. More than 150,000 delegators, including institutions like BitGo, Pintera Capital and Ledger,
Starting point is 00:01:30 trust Corus 1 with their assets. They support over 50 blockchains and are leaders in governance or networks like Cosmos ensuring your stake is responsibly managed. Thanks to their advanced MEV research, you can also enjoy the highest staking rewards. You can stake directly from your preferred wallet. Set up a white label note. Restake your assets on eigenayer or symbiotic or use their SDK for multi-chain staking in your app.
Starting point is 00:01:53 Learn more at Corus.1 and start staking today. This episode is proudly brought to by NOSIS, a collective dedicated to advancing a decentralized future. NOSIS leads innovation with circles, NOSIS pay, and Metri, reshaping, open banking, and money. With Hashi and NOSIS VPN, they're building a more resilient privacy-focused internet. If you're looking for an L1 to launch your project, Nosis chain offers the same development environment as Ethereum with lower transaction fees. It's supported by over 200,000 validators making NOSIS chain a reliable and credibly neutral foundation for your applications. NOSISDAO drives NOSIS governance where every voice matters.
Starting point is 00:02:39 Join the NOSIS community in the NOSISDAO forum today. Deploy on the EVM-compatible NOSIS chain or secure the network with just one GNO and affordable hardware. Start your decentralization journey today at NOSIS. Fernando, it's fantastic to have you back on. Last time you were on this show was actually four years ago. It's a really long time. Remind us.
Starting point is 00:03:06 In crypto, it's a generation or more. Yeah, it's like in four years, it's at least one generation. So remind us how did Balancer get started and how has it developed since 2020 when we last had you on? Yeah, so I've always been a fan of crypto in general, Bitcoin and Ethereum, and got involved in the early days of Maker-Dow, worked with Rune and Nikolai, and was active in the discussions around AMMs, and it was the early days in 2017, even before that. And the idea came in 2018 when I realized that AMMs didn't need to be. only the simple version of x times y equals k which implies that the pool always has 50-50
Starting point is 00:04:00 like the same amount of value in both in both tokens so yeah i i kind of slept left little for some nights and went through lots of maths and discovered that it's possible to have any number of tokens with any weights that you want like pretty similar to what an index fund or an et f would look like And that was balancer, balancer v1. We launched in 2020. And yeah, since then, how it evolved, we went more from like an end user focused protocol to developer-focused protocol
Starting point is 00:04:38 where people can build their own AMM innovations on top of balacers. So we kind of went in that direction with balancer v2 and even more so with balancer v3, which we can talk about now. But it's been a long journey. And, yeah, a lot of people now building a balancer. So very, very glad that we're here still like doing interesting stuff. And yeah, very happy to be here with you again to drink.
Starting point is 00:05:07 Super nice. So maybe let's talk about very early days of AMMs. So kind of like in my view, kind of AMMs were very much developed as a stopgap measure. because kind of, I mean, people had been used to central order book exchanges off chain, but implementing them on chain is actually very difficult because everything is kind of is ex ante. It's public, right? Kind of like you can front run things. And so that's kind of how AMMs kind of started off.
Starting point is 00:05:44 how do you see the evolution of AMMs in this space? How have they matured? Yeah, it's crazy how we learn things that today in hindsight feel just obvious, but it took us like for four years maybe until today we're learning new stuff, but only a year after we started the AMMs, we started discussing things like in permanent law, and then MEV, which then evolved to LVR, loss versus rebalancing. And we realized that there were lots of dark forests, ARP bots that were being there
Starting point is 00:06:30 mean in a way, like sandwiching innocent users. And then things like KALSwap came around to make Ethereum more fair or fairer. And yeah, so there's been a lot of evolution. And then Uniswap came with their V3, changing the landscape with concentrated liquidity, which was definitely groundbreaking. But that itself introduced some new challenges, like just-in-time liquidity,
Starting point is 00:07:00 where LPs put 100% of the liquidity in a very short tick or narrow tick when a big swap happens. And then people who are providing liquidity with a longer range. They just, yeah, got their, they get their lunch eaten by those guys who only apply to that narrow tick because they get proportionally almost all the fees.
Starting point is 00:07:25 So with new innovation comes new challenges. And I think we're still learning today. There's lots of interesting things that we're doing at Ballister and others are doing as well around mitigating math and LVR and our profits and really trying to return the, let's say, the profit or the surplus of the operations to the end user instead of to validators or to the MavBots or Arbor's.
Starting point is 00:07:53 We really want to make sure that the users get all of the return for the risk they're taking by providing liquidity or by doing trades as innocent, good flow as we call them. So very excited. I think balance of V3 is all about this bat that AMMs are still in their in their infancy. There are people who say like EMMs are like what they are now and there's not much to do. But then we see a lot of interesting things like priority fee mechanisms like discussed by Dan Robinson, who's an OG and someone we all look up to. And yeah, some very interesting ideas that keep coming up. So I think Balance 3 is a bet that this is going to keep happening and we want to be this platform for people to try new things around AMM design.
Starting point is 00:08:50 There's a lot to unpack here. And I think I kind of want to defer most of it until later in the episode. But I think we should note that AMMs are extremely susceptible to MEV and LVR, just because you're always at a disadvantage if you're the maker, right? Kind of like you ideally want to be the taker and kind of like if you have stay liquidity and kind of like prices have changed, that's really detrimental. And then also on top of that, if someone kind of actually is a somewhat unsophisticated taker, this potential revenue that should acquire,
Starting point is 00:09:36 to the makers, it often actually goes to arbitrary treasures. So they kind of lose on both sides. And kind of, I think kind of we should talk about how to mitigate MEV a little bit later. So kind of if when I think about other things that kind of have changed for AMMs over the past four years or so, it's kind of efficiency and cost reduction. Right? Kind of like, so you talked about this simple, constant product market maker, and kind of this also has changed dramatically, right?
Starting point is 00:10:16 Right. Exactly. Yeah, I think that there are, like, this is a, definitely, there are two examples of AMM innovation where efficiency comes in terms of capital efficiency, which means how much price depth or how much useful liquidity for. traders, which is translated in terms of bad depth, how much you can trade. For a given amount of dollars, you deposit into a pool. And Curve came with the first, in my opinion, innovation in that regard for packed tokens.
Starting point is 00:10:53 And we also have an implementation of stable swap on Bouncer. And yeah, and Uniswap also innovated in terms of making those positions non-farmeswap. fungible. So anyone can express their opinion in terms of what range they want to provide liquidity, which has also its challenges. So, yeah, I think there's different ways you can talk about efficiency and different challenges that those ways you solve efficiency bring to the table. So you already kind of mentioned kind of the main competitors in the AMM landscape. So there's uniswap and curve. And curve very much long. launched with stables in mind where kind of say you trade one
Starting point is 00:11:41 USCable coin against another and then kind of there's very there's very high liquidity kind of at kind of at the point kind of at in the middle so kind of you can trade them against each other really efficiently a kind of like even large sums which is not usually the case with you know vanilla AMMs and the other And the other one is Uniswap. So kind of how would you say balances positioned with respect to both of these? Yeah, we're a bit in the intersection and really exploring like the like build your own AMM. So AMM's made easy.
Starting point is 00:12:24 It's really kind of you have those two and then you have balancer kind of an intersection, but also expanding through third party teams like some of which we're going to talk about like cowswap building the cow EMM with Benocer and gyroscope and save finance and lots of others. So yeah, we I think we we are really positioning ourselves as a platform not taking any preferences or any favorites saying like we're going to be just like many token pools. You know, that is something that curve can do but it's not in a way that we can do like with flexible weights and flexible AMN logic. So we can have up to eight tokens per pool.
Starting point is 00:13:10 And the main thing that we're not decided is strategically not to chase after because we think that they already do a very good job at is concentrated liquidity. So Uniswap has pioneered that concept and we believe that we can add more value to the space by focusing on fungible liquidity. So whenever you think of balancer, you have a pool token that is like a representation of a share of a pool where all the users are equal.
Starting point is 00:13:43 So there's no risk of like there are sophisticated players doing just in time liquidity. So there are LPs just for the transaction and take all the fees from the other poor LPs that are humans. So we solve this by focusing on fungible liquidity. But within fungible liquidity, you can have concentrated liquidity as well, which is something that Gyroscope is. pioneering within balancer so yeah it's a it's a invariant shape that follows the the shape of an ellipse that's why it's an elliptical pool uh eclp concentrated liquidity lip to elliptical considerably so there are other ways to do interesting stuff without giving up on the fungibility so that that that that's how i i would put balancer amongst the other competitive when you look at non
Starting point is 00:14:33 fungible and fungible liquidity. So to me it's pretty clear why non-fungible liquidity would be preferable in many instances, just because you can do very concentrated liquidity where you're comfortable providing it and kind of it's much better APY potentially if you're doing it right. What are the advantages of doing fungible liquidity?
Starting point is 00:15:03 Yeah, so fungible liquidity is really about setting a level playing field. Like you ensure that sophisticated players cannot come and grab your lunch using just-in-time liquidity. So it kind of sets a known and easy to manage something that I call set and forget or, yeah, deposit and forget. Whereas if you're dealing with concentrated liquidity, of course, you can be, more efficient and say like I want to trade if between 3,200 and 3,300 and I'm going to make more fees than people who have a unity two pool or balancer pool but like you have to be very active you have to make sure that as soon as your your liquidity goes out of range then you need to re-buy half of the tokens to to go back to to play or
Starting point is 00:15:58 position your your your LP position closer to where the price is which means you're rebuying for more than you sold for or you're selling for less than you bought for. So it comes with a lot of caveats. So I would say concentrated liquidity is better for active, more sophisticated professional market makers. And fungible liquidity is better for, I would say, like, passive LPs might be,
Starting point is 00:16:29 have a not better connotation, but I think that's what it is. Like there's a lot of people who want to just put the money in an LP position and forget. So those are safe because the environment does not let active traders kind of come and eat their lunch, for example, through just in time or equity or through more advanced techniques that the normal human passive LPs are not in a position to do or to perform. That makes a lot of sense. So Balancer V3 just came out, or came out a short while ago. So what are the main goals of V3 over V2?
Starting point is 00:17:11 Yeah, so V3 is really taking that idea of Balancer is a platform for AMM innovation step further. So a lot of the hard work we could, and yeah, we spent like almost two years working on V3, maybe more, is really towards like making it easier. for anyone to develop their own pool or to innovate with their own AMM idea. So the devs experience improved by 10x at least. It's very much easier, a lot easier to create your own pool. You only need to define an invariant.
Starting point is 00:17:47 And that's it. All the functions like swap or add liquidity, remove liquidity, they all stand from this definition of invariant. Whereas in V2, you had to define all the different functions, like swap in for out, swap out for in. And they could be conflicting. So you could have an AMM that is not consistent. So it took more, more care for AMM designers to make sure that everything was consistent.
Starting point is 00:18:15 Whereas V3, as I said, you just like have this invariant, like the shape of the curve of your AMM. And then Bouncer does everything. It does scaling. It does rounding. it makes sure that your AMN cannot be exploited through rounding because we do rounding at the vault level in the direction of the pool. So we're kind of taking away a lot of the burden
Starting point is 00:18:42 that AMN designers needed to carry about, to worry about, sorry, NV2 to the vault. We have this idea of transient accounting. So you can do lots of transactions, add liquidity, remove liquidity, swap. And then at the end, you settle your tab, let's say like you're at a bar and you drink. And then just at the end you pay your bill. So it's similar. And by the way, a lot of the things we did for balancer v3 are similar to some things that UNISWP4 also has.
Starting point is 00:19:21 We even changed our names to make sure that we had the same names as UNIB4 because we want people to like, yeah, that are used to Uniswap before to also look at the balancer v3 and see if it's a good or a better fit. So we also have hooks which make it easy for specific things that you do before and after swap to be applied to a different set of fools without having to rewrite all the pool code, which was possible in B2. So you can always deploy a pool with specific code that is customized by you. So with the hooks on Balancer V3, you can just reuse hooks that exist. And we have a few examples of that. And maybe the coolest thing for the end user, I think, about Ballance of V3 is the new idea of boosted boosted, 100% boosted.
Starting point is 00:20:14 We had that in Valance RV2, and we're improving that by making, like before, they weren't 100% boosted. we're making them 100% boosted and we do that by and it's kind of technical so yeah maybe I'll just stop here and I can talk more about how it works but I'm very excited about boosted boost which means that instead of like
Starting point is 00:20:38 having to choose between blending your say die or USDC on AVE or adding liquidity to an LP with your USTC and die or your SDC and E you can do both like you can add liquid using your dye and then under the hood balancer will deploy all that dye to to Ave and turn it into a dye so people are trading dye and USC are dying and
Starting point is 00:21:07 and at weft but in the like under the hood balancer is making sure that this is being lent out to Ave and all of your position is earning yield so this is pretty cool and that's super cool because yields on particularly at U.S. dollar stables are really high. So kind of competing with this kind of as a liquidity provider is really difficult. Tell us how this works under the hood and kind of why it was difficult to going from partially boosted pools to fully boosted pools. Great question. Yeah.
Starting point is 00:21:44 So the way it, so first, why is it difficult? like in essence it's not hard like we what you can do in curve does that but um it's not very popular because of the the reason why it's not um yeah simple to do it which is like you could just have all the liquidity go to um a tokens let's use av as an example but it could be other landing protocols so if uh you want to have like both the swap fees like being an LP and also have the landing protocol, you can just put your A-Dai paired with an A-USDC on Bouser, and then people can trade A-D-I-S-C for A-O-S-C. But this is not what people want to trade. People have Dye, people have U-S-D-C. They don't have A-U-S-C or A-Di or the wrapped version of those tokens.
Starting point is 00:22:37 So really, the trading happens in the underlying token, right, in Dye and U-S-C, not in lending-W-D-W-D-Versions of those tokens. So you could solve that by having very kind of sophisticated aggregated, like logic, which one inch has and others like KOSOP also have. You can abstract away that from the end user and say to the end user you're trading the eye for your SCC, but I am going to AVE, I'm going to wrap it, and then I'm going to trade on Ballister, and then I'm going to give it back to Avey, you know, and do all that back and forth, which costs a lot of gas.
Starting point is 00:23:17 So this is quite hard to do because of a lot of gas. So what we did to solve this in Balancer V3, and we don't have, no one has that, so it's a pretty unique feature, which is what we call buffers. So what we do is very simply we have, it's like a mini instance of AVE inside the balancer vault, which has like a little bit of a dye, a little bit of dye, and then everybody who trades using balancer's vault they they trade actually they see dye as liquidity but they trade with in the pool that has a dye and a osac which is earning 100% of yield for alps but then balancer the vault looks at the buffer so the buffer is kind of has a die and die and wraps and
Starting point is 00:24:09 reps with the same rate as ave but much cheaper because it only reads the rate that Ave is offering without having to, if you had to wrap using Ave or unwrap, you would have to do all the update of the accounting of the whole like pool of Avey. So that's quite gas intensive. Even though AVE is so proficient and has improved efficiency over time, it's still quite gas-heavy. So what we do is we use this buffer. And then like, let's say you trade a little bit of dye for you to see.
Starting point is 00:24:43 you put dye in the vault, the vault puts dye in this buffer, takes some wrapped or some A-Dai, trades with a pool that has a-d-I in USDA-C, and then the A-USDC goes to the buffer of USCC, and then the user gets USC. So the user has the experience of trading die for USC, and there's no external calls to AVE,
Starting point is 00:25:12 because the buffer, the buffers of dye and USC are enabling that trade. Then, of course, what can happen is the buffer doesn't have enough die or USC to give back to the user because the user is doing a big trade. That's where I think the cool thing happens is that when the buffer, so the buffer goes back and forth, back and forth, and then whenever there's a big trade, then the buffer doesn't have enough. so balancer knows that, the vault knows that, and goes to Ave and then wraps or unwraps exactly the amount needed for the trade to be executed, plus putting the buffer back in the middle,
Starting point is 00:25:52 which means that this user that did a big trade, they're paying for the buffer to be put into the sweet spot, which is right in the middle. So for next trades, smaller trades, it can go back and forth, back and forth and still save a lot of gas for subsequent trades. So, This is something really neat that I think we are just starting to explore. And one thing that I think a lot of people think is that in layer two, it's not very relevant how much gas you spend because gas is so cheap, more so on ZK roll-ups because, yeah, it's really a free processing. But I think that it still can make a difference between like two sources of liquidity,
Starting point is 00:26:38 say balancer and uniswap. If balancer has slightly less gas for that trade, then that liquidity will be used by solvers on cowswap or by one inch or whatever aggregator, macha. So I do think that the gas discussion, even though less relevant for L2s, it can still be like a differentiator for sources of liquidity.
Starting point is 00:27:02 It will also become more relevant again once blobs fill up, right? So kind of like, I mean, the only reason why L2s are currently as cheap as they are is because kind of blob space is pretty abundant. 100%. We'll always be breaching that scalability moment where like, oh, things are going to be expensive because we filled up the, yeah, the ledger and we need more space and keys go up. So yeah, absolutely. How baked into the designers are, but could you in principle kind of switch this out for another month? money market or does it
Starting point is 00:27:39 have to be Avo? Will there be other versions that kind of use a different money market? So AVE is definitely our preferred partner. We've been together for a long time where they're close and they used Bouncer for their 80-20
Starting point is 00:27:55 pool for providing liquidity in the AVIT token. So it's also the like longest most battle tested protocol around. So we're definitely, yeah, kind of of bias towards AVEC, but the protocol is neutral. So the smart contracts work with a wrapper, which is 4626-26. So as long as your token is 46-26-competable, then you can use a boosted
Starting point is 00:28:24 pool. So other protocols like Morpho and oilers looking into it, there's also already other protocol that have boosted pools on Ballastor already. So it's definitely an open thing. But of course we, yeah, we kind of have a, at least in the UI, and the UI is controlled by its own team that has their own opinions. But I think the standard option is AVE, so it's just because we trust them so much. Cool. Yeah, that makes sense.
Starting point is 00:28:59 When you say kind of it's fully boosted, I take it. The part that's not boosted is the buffer, right? And I mean, the size of the buffer kind of has to be somewhat in relation to the total pool size and the average trade size, I assume. So kind of like when you say fully, it's probably like 95 or whatever percent, right? It is full because that's a great question. The buffer is not paid or is not filled by the LPs. So the LPs.
Starting point is 00:29:28 Oh, okay. Yeah, the LPs only put their liquidity in the pool. and by the way if there is no buffer it's fine because that means that all the all the transactions will have to wrap and wrap using yeah exactly so it's just a plus if you have a buffer it reduces gas for most of the trades and like you said perfectly put depending on how big the buffer is the more trades it can kind of enable without having to resort to an external call what how we deal with buffer so far is the projects are putting liquidity there because like protocols usually have protocol on liquidity so you don't need a lot to enable most of the trades in the buffers. So protocols that are creating boosted pools are pretty 100k, sometimes 200k in the in the tokens that they want to boost.
Starting point is 00:30:24 And very nice as well is that one token is so you only need one buffer to boost a token And that token can be in many different pools. So if you have a buffer for dye and A-Di, then A-Di can be in like A-Di-O-C, A-D-E, E-D-E, you know, A-Di, whatever. Every time you do this lag, which is boosted dye, then you use the same buffer. So it's kind of a shared common good that helps everyone to save gas.
Starting point is 00:30:55 Cool. Yeah, that makes a lot of sense. So when we talked about kind of like new features for V3, kind of the first thing that you kind of mentioned was improved dev experience, so kind of like making it easier for devs to kind of build good, well-designed AMMs on top of, on top of balancer. And the other thing that kind of you mentioned but didn't really go into was hooks. I'm interested in this. So kind of hooks are kind of modular customizations.
Starting point is 00:31:27 Tell us about what kind of logic. you see and what kind of logic you expect to see in the future? Great question. So hooks are really like this very interesting way to open up experimentation without creating dangers for developers or LPs and also kind of reusing, reutilizing code that's battle tested. So that's the beauty of hooks in my opinion. An example of interesting hook is you change the swap fee based on whatever like parameter.
Starting point is 00:32:06 For example, priority fees, those are very useful for mitigating Mav or LVR in chains that are priority fee sequenced. An example is based. Or L2s, right? L2s, yeah. So base is, it uses, it can change. nothing set in stone, but differently from Ethereum L1, they just take the transactions and order them by priority and execute them. The base, like Coinbase is not interested in doing money with MIV, at least so far, thankfully. Yeah, so if you are, if you're trying to be a MavBots and you want to capture a very good opportunity, let's say sandwich someone, to be able to get that opportunity.
Starting point is 00:32:56 What you're going to do is you're going to put a high priority fee for you to be like the first one to get it, right? What we do is we have a hook that says read the priority fee, which is something that is like readable in the transaction And then we say like that priority fee if it's above a threshold, which is kind of to safeguard users that are using MetaMask or other wallets that always have some small priority fee as standard up to five guay for example if you pass that threshold then you're considered to be a bot that's trying to extract meth from the four LPs who should because because kind of you're paying to kind of be early in the sequence and kind of like get to fulfill some sort of vulnerability or kind of like a
Starting point is 00:33:50 up against something that won't be there for a long time right kind of like exactly perfect exactly So what we do is, like, we calculate the swap fee of the AMM. So we make the price worse, less attractive, as much, or proportionally to how much the priority fee goes up. So if we read a transaction that has a very high priority fee, we increase the swap fee to extract more value to the LPs. So this way we effectively make sure that if you're trying to get MEP by. paying too much the sequencer, we say the price is worse. So it's kind of a very, very interesting way to say the share of profit that this Mav opportunity created will go to our users and not to
Starting point is 00:34:43 you bot. It's like text the bots. Exactly. It's based on an article. I don't think it was the first article talking about that, but Dan Robinson, as I mentioned, wrote a very interesting paper on this and we're like implementing it I think it's the first AMM that's doing that so the like the very flexible infrastructure balance every three allows that and we're I think we're launching it like next week or so we're already it's already audited so and also the cool thing as I mentioned of hooks is that they only have a very small surface of kind of interaction or or surface of attack because with
Starting point is 00:35:26 with a swap hook, it's a view function. It only returns to swap the new swap amount and swap percentage. And that itself cannot, it's probably not something that can drain the AMM or foot LPs and risk because the worst it gets is the fee goes to 100%. And then the trade is like no one is going to trade with that pool. But it cannot be negative, which would be draining the pool. So it's something that people can just interact and interact and innovate, iterate a lot without the risks that AMM design bring with it. Cool. What other hooks are you working on or looking forward to? Yeah, so we have the priority fee hook.
Starting point is 00:36:15 We have the stable surge hook, which is very interesting as well. So if you have a stable pool, so two assets that are correlated like USC and die, if the peg is lost or is broken, then you have like, I don't know, let's say die for 70 cents. The stable surge hook, what it does is it charges a higher fee towards the side that you don't want the pool to go. So if you want to dump more dye and make the pack go even worse, there's a higher fee.
Starting point is 00:36:47 Whereas the fee that brings the pull back to the pack to where we want it to be is lower or even zero. can't be negative because that opens up problems, but it can be virtually zero. So we kind of incentivize the spread to go towards where we want the pool to go. So that's an interesting one. What do you do with a saber kind of deep pegs for a good reason, right? Kind of like, so for instance, say someone has invoked the global settlement with Maker and then kind of die deepags.
Starting point is 00:37:21 I mean, that's pretty reasonable. wouldn't you have to kind of disable this hook? No, because that's a good question. What the hook would do is it would just like not enable trades in that direction. So let's say the swap fee or spread grows a lot. So there's no trades between 80 cents or die and 60 cents. So even though the price is like 79, right? it's almost 80, which is the upper margin where we want the AMM to trade.
Starting point is 00:37:58 It still has all that margin to go back and forth till the 60, where our AMM is just saving our users. So in a way, it's protecting the LPs by not giving away more, let's say, USDC, which is the one that's still at $1 because, yeah, it's not worth it. So it's a trade-off between swap fees. So we give up on being traded on, so generating swap fees. Because there's a lot of cases, or most cases, when the Pag is broken, it's something that could be dangerous and it could mean that there's a problem in one of the tokens.
Starting point is 00:38:36 And then the Poole will just get to drain or drain all the good tokens. So that's another cool thing of the Stable Strait. The more you get to the Pag being broken, the more you protect the token that's still in Pag, and you don't sell it. So, yeah, it's fine. You don't need to deactivate it, but you still, like, you trade less. It's like giving up on swapping fees, swap fees for, yeah,
Starting point is 00:39:06 the chance protecting LPs and in the event that that deep bag is not going to be permanent or is something like temporary or related to a bug or some instability of the system. But as an LP, you're always allowed to withdraw. Withdraw. Anytime. Yeah, that's a premise that Bell also has. It's actually enforced by the vault. We have functions that allow the LPs to withdraw their liquidity
Starting point is 00:39:38 without even talking to the pool contract at all. So, yeah, and that's just super important. Like any pool that has code that could be broken because of a bug or whatever, balance the vault, it's almost like, now that I think of it, it's almost like the L2's
Starting point is 00:39:57 kind of having this forced exit mechanism. You know, if the L2 stop creating blocks, then you can go to the L1 and just force a withdrawal of your L2 funds and bridge them back.
Starting point is 00:40:12 So it's kind of similar. The vault doesn't need to talk to the pool to allow users to withdraw their funds. Yeah, I think a lot of L2s don't actually have this implemented yet. They say they have or they say they will have or they should have. We're going to get to this eventually. Exactly.
Starting point is 00:40:30 It's one of the stages of the ladder of L2s, right. Cool. You alluded to this kind of like in the very beginning of the podcast. So kind of you talked about MED mitigation. We already touched on this kind of with and the priority fee hook where kind of you surmise that kind of like anyone who's willing to pay. a higher tip is probably trying to do something extractive and it's not just trying to be nice to the sequencer.
Starting point is 00:41:05 So there's another M-A-V resistance mechanism with cow AMM. Can we talk about that? Because kind of like that's less circumstantial in a way. kind of with them the priority fee hook, you're just assuming that because someone is willing to pay for the first spot, that they're trying to do something malicious or extractive. How does it work with the Kauaiam? Great question.
Starting point is 00:41:40 Yeah. As always, it's like a trade of. I think my personal preference is what Kalswai. does or the cow emm that's powered by by cowswap which is really the like to take a step back like any v stems from the the fact that there is adverse selection so there is a um an unfair as you said so tricky like the the the lps are like they are on chain like you cannot update prices instantly there's like block times and that there's gas costs to change things on chain whereas traders, they have instant information. You have like all sorts of flow of transactions and
Starting point is 00:42:26 mempool. So you have a lot more oversight of the price of assets. You have access to all the off-chain information. So it's really an unfair game. What Cow Swap does, and I'm a big fan of of Cow Swap, by the way, is like they bring this knowledge to the table by having this competition between solvers and they make sure that there's a surplus that has to go to the users and the solver that maximizes surplus to the users in this case the cow amm is considered a user which is like the whole the whole novelty of this design like usually only users that put trades on cow swap are considered users and they get the surplus for cow amm the amm itself is like a user So it also has like the surface included in the calculation for the winning solver.
Starting point is 00:43:20 So it really, so Kau-Sop allows this, this, this kind of disadvantage of on-chain LPs to kind of be counteracted, counterbalance. So with Kau-A-M-M, you are sure that you are selling whatever you have in your, in your AMM, pool for the market price because there is competition between solvers and the one that provides the cow AMM with the most surplus is the one that's going to win. So it's really like you have like a swap fee that is it's not it's variable. So like I said, like you can increase the swap fee to give more value to the LP's by looking at the priority fee or you can increase the swap fee by looking at how the competition between the solvers is willing to give more to the LPs to get the straight. So it's two ways of returning value to the LPs.
Starting point is 00:44:25 And yeah, I like it a lot because it's just it has more information from the whole ecosystem. It's not just some MabBots that are doing like trying to extract and giving to the sequencer through priority fees. It really involves all the solvers of KAL swap, which is getting bigger and bigger and has more and more participants. So it's fair and fair. But the problem is the downside is that it's not permissionless as the priority fee hook. So the priority fee hook, the beauty of it is that anyone, it's like open, anyone can post their transaction on the base sequencer. Whereas for Kau mMs, it works if you allow only solvers of Kausau or Kalswap to enter. interact with that liquidity.
Starting point is 00:45:15 So it's that trade-off. But in my opinion, as COOL swap grows bigger and bigger, and there's lots of solvers and a lot of diversity in the solver ecosystem, I think this is a trade-off that we're willing to do it. We're going to publish some results soon, but we're super excited. Like with smaller pools on COEMMs, we have much better APRs from swap fees than compared to balancer, vanilla. weighted pools or uniswap v2 pools, like even being a lot bigger,
Starting point is 00:45:47 cow AMM pools are doing a lot more APR, so kind of protecting the users and giving back swap piece to them as compared to the conventional uniswap V2 or balancer amms, which is amazing. Something we're going to be building on more and more, and we're going to expand cow AMMs to balancer v3, which is something we're working on right now. Are there kind of like benchmarks that you can give us? So kind of like how much more APR can I expect to kind of get as a cow AMMLP? So I've just today seen some numbers by the cow swap team. And it's sometimes like four, five percent annualized inputs that are much smaller.
Starting point is 00:46:36 So the results are really like really promising. And I'm not going to give you any hard numbers because, I might be wrong and more like more judicious analysis has to be done. But it's as much as like 5% annualized more. But it makes sense, right? Because like what Kausop does is really like it lets people trade with the price of the market. Even though the pool has a stale price, like you said, for it. The competition ensures that the pool gets its fair value for the assets,
Starting point is 00:47:12 which increases the APR considerably. So toxic water flow is effectively just filtered out. Perfect. That's right, yeah. Cool. One more thing that we also kind of like tangentially already touched on. And that's kind of scalability and kind of your L2 and multi-chain strategy. Kind of like what we've seen increasingly in kind of like the theorem ecosystem is that liquidity has splintered.
Starting point is 00:47:42 dramatically between different altos and contrary to kind of what what we had hoped for initially these altos are very much not interoperable so kind of like despite the fact that they have
Starting point is 00:47:58 this shared security layer you still have really long settlement time so in principle kind of like say go from Arbitram to base and back it'll take you
Starting point is 00:48:12 two weeks. You might as well send a postcard to the other side of the word, right? So what you actually have is you have, you know, arbitrage between different L2s and kind of like it's very liquidity intensive and and so on. How do you guys think about balances kind of multi-chain and multi-altu strategy? That's a very hard question. And like I'm just representing my views. I can speak for all the balancer community. But I do think that this is such a hard problem. And one that a lot of people are working on, very, very good people, much more intelligent
Starting point is 00:48:59 than me for sure, but probably than our team with a lot more resources. So I do think that we should not try to create, you know, new. protocols for cross-chain swaps or things like that. I think we should try to kind of stay in our lane and make sure what we do, we do the best we can. And yeah, I'm not a fan of going the app chain route. I think this is going to cause even more fragmentation, like you said, even if you're part of the like the super optimistic chain or you have a base.
Starting point is 00:49:42 roll up. I think there is always fragmentation that is going to happen. Maybe it's solved in the future and again, I hope that those brilliant minds in the Ethereum space are going to be able to solve it. As a user, it hurts me a lot to
Starting point is 00:49:58 have that fragmentation. Like I said, it's not good UX. It goes like in the direction of all the like Solana versus Eith like North Star and everything that I don't think we need to get
Starting point is 00:50:12 into but so yeah we are trying to be as good as we can in in what we do but what it comes to our strategy for multi-chain we we want to be in the chains that our like our partners require or want us to be so we don't want to be on all chains because it does kind of dilute you know like capacity of the team and making sure we can execute with excellence so but Given we are a protocol for autos subdual on top, we have to be on the chains that our partners like, you know, Quant AMM, they have very interesting kind of strategies that use ZK proofs. We haven't talked about them, but I hope we have some time too.
Starting point is 00:51:00 But, yeah, teams like them, like they want to be on ZK Sync or whatever chain, it's kind of how we're approaching our strategy. supporting the team's built on top of Ballasor and our close partners as much as possible. And we're not tackling directly the challenge of like cross-chain swaps or liquidity, yeah, at the moment at least. Yeah, I think that's fair. It's a hard problem. Let's kind of dive into the other bigger projects building on top of balances.
Starting point is 00:51:40 So kind of you already mentioned. quant AMM, and I'd be super interest to kind of hear more about them. The other thing that kind of really piqued my attention was Gyroscope. So maybe you can give us kind of like a short overview of what they do and how they
Starting point is 00:51:56 leverage balancer. Sure, yeah. So disclosure, I am an investor, an engine investor in both those protocols, though I am biased, but I do think they're amazing.
Starting point is 00:52:11 gyroscope has been around for a long time they are basically the initial idea is and I think it expanded a bit but is to have this GID coin which is a stable coin that is based on like how to compartmentalize
Starting point is 00:52:31 risk and making sure that whatever you have in your basket of assets that collateralize your stable coin if something fails or goes off bag you still have the kind of the system dynamics to avoid like a DPEG of this coin that is basically built by collateralized BMM pools on top of BALSER. So it's quite big brain stuff, but yeah, has been created by really brilliant guys that, yeah, from the UK that have been, yeah, very, very much.
Starting point is 00:53:11 a fan of since the early days. And I think they've been around for maybe four years already. So, yeah, they also created the ECLP that I mentioned. It's a very gas-efficient AMM based on elliptical curves or elliptic curves. Yeah, so they are amazing and they have built some balancer v2 and are now migrating to balancer v3. And kind of as an aside, it was great to see how the devax increase or improved because most of the migration process was like deleting code, you know. You delete this, this, and it's very, very much watered down version of V2 is what they need for V3. So kind of validated our hopes of increasing improving VX. Quant AMM is really about like this initial, like original idea of Vanceur as an index fund.
Starting point is 00:54:06 And it's actually something we're pursuing not only with quant AMM, but with cow AMMs and cow swap as partners, this idea of like index funds and ETFs on chain. Like the main reason why, and I'll talk about that, but just quantum AMM, it's really like how to have index indices and ETFs or exposure of like a pool of assets with a very smart kind of management that's the, on-chain, potentially with ZK-approves. So you have very complex strategies that you don't want to make public for people to kind of copy you or front-run you. So they have strategies that are all implemented on-chain, but use ZK-D-E-Props or, yeah, ZK chains to make sure that it can be implemented on-chain without disclosing what it is and in a gas-efficient manner.
Starting point is 00:55:04 So it's really like using Balance of V3 as an asset manager and doing very sophisticated strategies. We're very excited about them. They got a grant, they got funding from other VCs, and yeah, we're launching. I think they're already in beta and they're going to be quite big, I think, on Bellas of V3. So I was saying about the, apart from QantasMM, this idea of indices and ETFs. I think we have tried that in the past. And I think it was just not the time. It was too early.
Starting point is 00:55:42 You know, it's like. Yeah, I know that feeling. You know, like MySpace. And then Facebook comes at the right time, executing the right way. So I think the one thing that was missing back then and was the cause for indices like index co-op. which I love. I think the idea was great. Like they leaked a lot of value because of this adverse selection, like arbors and traders have off-chain information,
Starting point is 00:56:10 and they just extract slowly the value from those indices by having better prices than the market. But now we have the tools we just talked about to prevent Mav. So all of a sudden, indices on-chain are a thing again. So you can have exposure to Nvidia and other other like assets, real world assets and have an index fund
Starting point is 00:56:37 on balancing. By the way, we launched with the like help of like actually their initiative, Carpet Key, which is part of the NOSIS family, as you know. Amazing guys, they, yeah, together with BACT, they launched the first pool where you can like trade assets and stocks like Nvidia.
Starting point is 00:56:56 And you can only do that. on Balancer. So that is something that excites me a lot about the, yeah, the future of Balancer and AMMs in general. And it's got amazing yield as well. So exactly. It's like I'll make sure my lawyers don't hear this otherwise kind of like they're not in investment advice. They'll make me deleted for financial promotion. But yeah, I mean, it's kind of like the years you can currently get on Jane. It's kind of in. things that are not inherently risky or not inherently more risky than doing it on Robin Hood is is is insane exactly so Fernando kind of like when I kind of zoom out a bit kind of I heard two
Starting point is 00:57:45 to somewhat different stories about kind of like who you guys are catering to right kind of like on one hand you're catering to people who just want to let their capital sit there and not be sophisticated traders. And on the other hand, you're kind of looking to cater to protocols. So kind of like if I were kind of a business person, kind of I would, you know, I would kind of differentiate these into kind of like B2C
Starting point is 00:58:15 and B2B2C kind of branches. How do you think about them? And how difficult is it to kind of like corral them into one product suite. That's a, yeah, great question. And I agree with you that that impression might be floating around for listeners or for you. So the way I would frame it is like the end goal is really to be a platform for others to build on top and innovate using their own AMM ideas. So the focus is for others to build a balancer.
Starting point is 00:58:54 And I would say that what we're doing by having our own types of pools or joint projects like the KauaMM with Kalswap and investing or being very closely related to QantMMM and JARCope, what we're doing is like we're trying to give examples of successful projects or protocols that are built on balancers. So with the priority fee hook, for example, our main objective. is to showcase how to use Balancer V3's hooks and make sure that other bavs or teams know, like have an example of something that works. So yeah, it's really like bootstrapping Balancer V3 or Balancer in general for others to look at us and see there is like cool things that we can build on top of balancer. So once we have some traction and lots of teams building on top of balancer and and kind of creating cool stuff,
Starting point is 00:59:56 then I think more and more our focus will kind of transition to helping others, like unblocking them as opposed to our team, and there's many companies or teams in the Balancer ecosystem, as opposed to our teams directly involved in new projects. Like we want to be enabling others to build interesting stuff in the Ballaster ecosystem. So that's how I would, if it makes sense, how I would frame it.
Starting point is 01:00:22 Absolutely. Then I want to zoom out even more. So we kind of started off this episode by kind of elucidating how AMMs were initially kind of this stopgap thing that kind of enabled us to kind of do on chain trading without opening ourselves up to being to being sandwiched to death. Now that kind of we have much more advanced cryptography, in principle, we could put central ledger, older book exchanges back on chain. So do you think AMM are going to be an interim solution or is there kind of a long-term space for them in the ecosystem? I think it's the latter. I think there is a long-term space for them in the ecosystem. And there is always going to be like the fast trading, like high frequency, strategy, teams or bots that are probably going to use more concentrated liquidity or if you'll always centralize order, limit order books. That is just more efficient. And if you can do that on chain, it's even better.
Starting point is 01:01:47 and you have like chains like Solana that want to be, you know, like the ones where people can do that. So it brings with itself scaling problems. There will be L2s on Ethereum that will be kind of more suitable for that. But I do think there's always going to be some space for passive LPs who want to just deploy capital to, let's say, L1 or an L2. that has higher fees. And they don't want to be, like, actively trading or managing their positions. So even in today's landscape, let's say in the future, nothing like new is created. There's no breakthroughs, which I doubt.
Starting point is 01:02:34 I'm pretty sure if not every the case. Even in today's landscape, I think there is space for AMMs. But given that AMMs are evolving and there's, like, ways you can mitigate. LVR and MET. This is going to be, in my opinion, even more so the case that there is space for AMMs. This is my kind of bat. I could be wrong, but I'm pretty sure. Like some people called AMMs like that.
Starting point is 01:03:02 There's just like X times Y equals K and that's it. And then UNiswap V3 came and then like lots of things that we're doing came. And I'm sure like in four years it will be hard to recognize the space and how much it will have evolved. I'm on the not saying AMMs are going to dominate and be the one in all, but I'm sure there's going to be room for them in the future. I'm pretty sure. And going on past data in four years is going to be when we will have you on again. So we can kind of pick up where we left off then.
Starting point is 01:03:36 Exactly. So Fernando, where can listeners learn more? Where can they kind of start interacting with the balance ecosystem? where can they start building their own protocols on top, where can they contribute hooks and so on? Yeah, I think the best way where you can ask questions and interact is discord.balancer.5. That's where most technical discussion take place.
Starting point is 01:04:02 Of course, there's our forum, forum. Forum.balancer.5 and our docs as well. If you go to balancer.5, you're going to see all those different links. but also of course the X handle at Balancer is where we talk about the latest and we have some spaces and discuss with partners. So yeah, I think that's where you should find us. Perfect. Thank you so much for coming on, Sanando.
Starting point is 01:04:31 Thanks, we thank you for having us. It was a big pleasure.

There aren't comments yet for this episode. Click on any sentence in the transcript to leave a comment.