Balancer v2: Generalizing The AMM

ETHCC 4 · July 2021 · 25:34

Jeremy Musighi introduces Balancer v2’s single-vault architecture, custom AMM logic and asset managers. He describes examples of how DeFi teams can use those capabilities for different applications.

Speakers

Topics

From ETHCC 4, hosted by Ethereum France.

Transcript

hi everyone uh my name is jeremy musigi i'm head of growth at balancer labs i'm going to be talking about balancer v2 and some of the ways that uh projects in d5 are using balancer v2 as a platform uh building very interesting uh products and services on top of it and integrating with the with the art technology so uh first i'm going to talk about sort of the areas of improvement from balancer v1 to v2 but actually before i do that

you know balancer from the beginning has been designed to be the most flexible amm protocol balancer is both a automated market maker which functions as a decentralized exchange as well as a an automated portfolio manager so it really serves primarily three audiences one is traders who use the amm to exchange erc20 tokens with minimal slippage the second is crypto investors who deposit their assets into the balancer protocol and generate passive yield uh helping them you know make their investments more productive

uh and the third is developers who use balancer as a platform for uh building financial products and services so we'll go into some examples of that but first we're going to talk about you know what's so cool about balancer v2 so four primary areas of improvement and innovation and balancer v2 are security flexibility gas efficiency and capital efficiency and we'll dig into each one of those and we'll talk about you know some of the key features of the protocol so first is that

balancer v2 is designed uh as a single vault architecture so all of the liquidity pools in balancer are held within one smart contract and this offers a lot of benefits as far as the efficiency in cost on interacting with the protocol when tokens are traded from one pool to another within balancer they're not uh moving uh on chain to from one smart contract to another there's no token transfer required uh that really cuts down the costs and makes the operation more efficient also

this design enables something really cool which is that the amm logic on balancer is separate from the liquidity pools so that actually creates a very interesting design space for innovation so all of the as i said all the pools on balancer feed into this one vault and the vault manages uh all of the tokens and it handles all the accounting for all of the liquidity pools on balancer so this is just an illustration kind of showing the difference in architect architecture from v1 to v2 in v1 every liquidity pool was its own separate smart contract

and that is you know relatively inefficient compared to how v2 is designed um so um getting into this idea of customizable amm logic in balancer v1 we had a couple of pool types but in balancer v2 the number of pool types is actually unlimited anyone can create their own invariant or custom trading curve just as you know before balancer v2 if you wanted to do this you would pretty much have to build an amm from the ground up yourself you'd have to do you know take care of

all the accounting all the security you'd have to bootstrap liquidity for this you know new uh protocol in balancer v2 all you would need to do if you had a new concept for an amm is to implement the new um math within balance or v2 and deploy deploy liquidity pools that follow that logic um so most of your heavy lifting is uh already taken care of and you're also not isolating your liquidity uh in a brand new platform that is um you know separate from the rest of defy so this feature uh really acts as a launch pad for innovation amongst amms

and that's why the title of this talk is that is balancer v2 generalizing the amm where we didn't just build a new amm we built a an amm of amms a platform for anyone to create their own amm efficiently easily and effectively so today you know balancer labs has developed three types of pools for balancer v2 those are weighted pools where just as in balancer v1 liquidity pools consist of assets that you know have set weights

that can be anywhere between 98 percent and 2 you can also hold multiple tokens within one pool as opposed to some other amms that you may be accustomed to where um you know they're just two token pools that are split 50 50. you can have two token pools that are split 80 20 for example but you can also have pools with three four five six etc different tokens and then you have stable pools very similar to curve and very much inspired by you know their innovative developments where it's a liquidity pool that is designed for assets that have that are very close

in value such as stable coins or derivatives of the same product and smart pools are they're like a liquidity pool that has superpowers because they can dynamically change their parameters while they're you know running with live liquidity this is also a very unique feature of balancer and we're gonna look at how some teams are using this to their benefit and to the benefit of their users of course so uh another cool feature in v2 is asset managers and an asset manager is a solution for capital efficiency in amms

one of the issues that has been true historically in amm is that most of the capital most of the liquidity that's held within the protocol is actually unused most of the time and so you know the idea was how can this capital be you know used more effectively if it's sitting in a pool it's not being needed for fulfilling trades on the platform what else can be done with that so an asset manager is a smart contract that is authorized to manage the assets

within a liquidity pool and that means that it can take unused capital and allocate it towards other productive use and at any given time the majority of capital uh in most amms is unused so this means that the pool can function just as well as before it'll still execute the same trades but it will do that with less liquidity in the pool thus the idea of more capital efficiency this is an illustration of what i'm talking about so we're looking at on the left side we're looking at a

two token pool and the assets that are sort of moving in and out of this pool on the right side where uh you can see a breakdown between like two categories of these assets you have the cash amount which uh refers to uh sort of the the liquidity that is being constantly needed you know for trader demand to make sure that like trades are being fulfilled on the platform and then the rest below that is the invested amount this is the amount that has actually been taken outside of the protocol and invested somewhere else so that every liquidity provider that is invested in this pool

is generating what they would have the yield that they would have been generating already they're you know they're generating uh fees and you know if there are any other incentives that are in that pool they're still receiving all of that but at the same time they're also generating additional yield from wherever that capital is invested elsewhere and again we'll get into specific examples here this is just everybody loves stani so it's a quote from stani but ave is the first partner that is building this asset manager feature so what that means is there will be pools on balancer that have ave as their asset manager and

the excess capital in these pools while they're generating yield within balancer are additionally generating yield in ave through their lending protocol as well so that that really the whole idea here is like really maximizing gains for liquidity providers on balancer gas optimizations uh as i mentioned before when gas when tokens move in between pools on balancer there's very little gas required uh another thing that is possible in v2 is to hold an internal token balance within the balancer vault so it's kind of like having a wallet within balancer so

if you're a high frequency trader or if you're just you know trading on a regular basis or if you're an arbitrager you don't need to be um you know withdrawing tokens out to your wallet each time you make a trade you can kind of keep them inside balancer and continuously make trades um very efficiently at a very low cost beyond that you can actually make what's called a flash swap where you can uh if you if you're an arbitrager and of course this can can and will be done programmatically you identify an arbitrage opportunity between two pools uh or or three or however many pools and

you can execute that arbitrage trade without actually having any tokens of your own up front because it doesn't cost you anything you're actually just finding an imbalance putting it back into balance and receiving the profit directly without having that upfront investment so that's really a dream for for anyone who's an arbitrager we'll skip through that so let's talk about building on balancer v2 as we mentioned ave is building the first asset manager on balancer v2 they are also using the

balancer protocol currently balancer v1 but this will eventually migrate to balancer v2 where they've set up an 80 20 ave eath pool on balancer which is a core component of their safety staking module on the ave protocol which you know plays a really key role in the security of their platform and is a great use case for other teams to replicate element finance is using balancer v2's custom amm logic to develop their own

custom amm they've implemented their own invariant or their own custom trading curve on top of balancer where they've created their own type of pool on balancer and this is designed for assets that converge in value over time and by using this new type of pool this enables element finance to offer something that's very uh rare but sought after in d5 which is a fixed yield in d5 so fixed yield assets power pool is uh also a really

interesting project that is taking advantage of balancer v2 power pool offers structured financial products uh like token indices smart indices and automated portfolios and they do this by using smart pools on balancer which as i mentioned can dynamically change their parameters in their case in the case of power pool balancer smart pools are used to dynamically change the weights of the pool in order to follow strategies that pertain to the financial products

that they're creating so a balancer is acting as this underlying infrastructural layer and power pool is offering this very uh cool product on top of that gnosis is also a project that is closely integrated with balancer we announced together the balancer gnosis protocol a few months ago where cal swap is settling trades on balancer v2 and

really has created the best user experience for trading in d5 if you haven't used it yet i i highly suggest checking it out and this solves several problems um such as you know mev uh optimizing price feeds and also um offering trades that don't require paying any eath for uh gas so rather than paying for gas you have solvers on gnosis that execute trades for you and they essentially take payment for that service in the token that you're actually trading

rather than having to pay each for gas so you can think of about users who you know maybe don't have any eath or are not as familiar with defy i think that's a big barrier to entry that it really brings down for them and cow swap and balancer v2 the trading on bouncer v2 are one in the same the trading experience on balancer v2 and calswap really mirror each other um and and they're fully integrated into each other so it's it's very exciting that you know balancer is going to soon be able to offer this best in class trading experience so that's it i'm happy to take any

questions thank you yeah thank you for the presentation so i want to ask about the gnosis partnership and about this co-swap so what is the changing volume at co-swap right now so is it work what is the trading volume of cal swap yeah yeah how much trades they execute yeah i wouldn't have the number uh off the top of my head maybe the gnosis team would uh yeah yeah i can tell you that it's pretty

popular but i don't have the exact figures i can look that up and get back to you so if part of so if part of the pool is moved to some other d5 protocols and then if there is a run and lps wants to withdraw then there have some real scrap right because it's not very like certain yes how much time it will take to liquidate that positions yeah that's uh the responsibility of the asset manager this is a permissionless feature so um you know any anyone who creates a liquidity pool that has an

asset manager which by the way not every liquidity pool and balancer has an asset manager there will be specific pools with specific asset managers and you know basically it's the asset manager's job to communicate how they're going to handle their strategy and it's their responsibility to make sure that they're responsibly managing how much they're keeping in their cash balance versus their invested balance and recognizing their strategy for how they would withdraw from other investments and you know return capital to the pool and make sure that that happens in time not only to make sure that trading demand is always fulfilled but that as capital is withdrawn from that pool

by liquidity providers that um you know the the pool doesn't end up uh you know illiquid right but you know there's like a non-zero risk that helps there isn't there is a risk um and yeah for any lp who uh invests assets into a pool that has an asset manager that is a risk that would be very important for them to provide an insurance or is there an insurance product around it so asset managers haven't launched yet i think that i can tell you that there are insurance protocols that are offering insurance for balancer and i think that would

be you know a great uh feature for them to focus on so the balancer is not in the insurance business but i think that this would be a great opportunity for insurance protocols to get involved with uh sorry uh so why did you choose to build as managers yourself and not use like urine vaults or or things like that well first of all urine is is building with asset managers as well so it um i think that like the framing of your question uh balancer has built a feature that allows anyone to build an asset manager that can connect into a balancer pool including urine so yearn is actually now working on developing an asset manager that can

manage pools on balancer it's a win-win where you know if you're a liquidity provider in that pool you can benefit from the yields that that pool itself is generating through trading activity and from the yields that are that would be generated in this example from depositing those assets into urine vaults so it's not it's not either or uh does that make sense yeah definitely thanks thank you regarding um regarding um let's say you had two identical pools except one uses an asset manager and one doesn't um you know given they have the same amount of liquidity and

let's say the one with the asset manager deploys most of its unused liquidity to um you know whatever strategy it's using is it fair to say that it'll incur a higher slippage on a trade or does it somehow in a trade you know reclaim that liquidity from the asset manager strategy to ensure you know similar slippage yeah so um there are two processes at work on the one hand there you know balancer uses sor which is stands for smart order router which will always locate the most uh you know efficient liquidity and the best slippage for any

trade so if a certain pool is less liquid for a certain asset compared to another pool then the more liquid pool will be chosen to to you know cover that trade at the same time the asset manager that is monitoring uh the you know trading demand and trading flows and their like capital position is going to be constantly making sure that they're replenishing their uh you know available like cash amounts within that pool we can bring a mic here yeah if those two pools have the same amount of liquidity added they will have exactly the same slippage

even though one of them has eighty percent of the assets invested on ave for example what might happen is that if the trade is too big that one that has the asset manager would fail because it would require more assets than the it has as cash available in the vault so the pool cannot trade more than it capped in the vault as a buffer does that make sense yep yes so we also like iphone powerpoint so we worked on this asset manager thing so there are you know situations like our safety model where you cannot get tokens back fast because it's called down period but for example for x sushi for other simple strategies you can get them fast so it means that if

if the trade is larger than cash amount in asset manager there should be a special method to get these tokens back of course it will be a little bit more expensive like in terms of gas but the trade will be settled so it depends on particular asset particular as management strategy and of course if we if somebody wants to to to make new asset managers strategies for balancer which they should focus on on uh things that you can get back fast i think yeah yeah exactly i think like uh investing asset managers investing capital from liquidity pools into illiquid strategies is probably not a good fit um the the asset managers on balancer v2 i would i don't control them but i would

expect that they would be focusing on liquid strategies where capital can be retrieved uh very quickly so one thing that's interesting also is that that the fact that the tokens are not liquid and cannot be put back in the pool can serve as a circuit breaker so it could be good if something gets hacked and the price falls like you would stop trading that token so you would be protecting the lp's money so there's like a functionality of circuit breaker there which is also interesting yeah okay thank you everyone

you