Join 100,427 users already on read.cash

Balancer Protocol: A Thorough Analysis

1 20
Avatar for Concave
Written by   9
5 months ago

Balancer Protocol: A Thorough Analysis

Balancer could simply be defined as an AMM (Automated Market Maker) built on Ethereum, but this definition would not do justice to a protocol that has proved to be one of the most interesting DeFi protocols of the last few years.

Balancer could simply be defined as an AMM (Automated Market Maker) built on Ethereum, but this definition would not do justice to a protocol that has proved to be one of the most interesting DeFi protocols of the last few years.

Started in 2018 as a research project by Balancer Labs, an organization founded by Mike McDonald and Fernando Martinelli, the protocol was launched in 2019 in its v1 version, and since then has quickly become a core building block in the DeFi space.

The vision that has driven the founders was that of building a permissionless asset management protocol to enable anybody to turn their portfolio into an index fund, but with a substantial difference when compared to index funds in tradFi: rather than paying a fund manager to rebalance the fund, the individual providing the capital would earn fees from traders that would rebalance the portfolio by following arbitrage opportunities.

___

Balancer v1 vs. Balancer v2

Even though Balancer v1 proved to be a product of absolute value, Balancer Team recognized the need for an improved version that was released in May 2021.

This evolution of the protocol was the result of the many feedback received by other teams that built their products on top of Balancer v1. Martinelli and MacDonald realized that a different and more flexible architecture was needed to meet the needs of the crypto industry.

The main core difference that came with v2 is the Balancer Vault, a single contract to hold and manage all assets added to the Balancer Pools.

In the next paragraphs, we’ll have a look in more detail at the core features that make Balancer one of the most powerful and used protocols in DeFi.

____

The Vault

Thanks to the new architecture of Balancer v2, the vault allows the separation of logic from the accounting and management of the pool. This not only simplifies contracts but enables users and developers to create new pools with minimal effort and focus only on the pool logic that is now limited to swaps, joins, and exits.

The vault can host many different types of pools, providing they respect a few requirements.

Differently in v1, where every pool had its own vault, in v2 one single vault holds the assets of all pools, and users who want to create their own AMM just need to define pool logic and plug the pool into the vault.

This way gas cost is reduced as multi-hop tradings happen in the vault without generating on-chain transactions, thus improving gas efficiency.

Even though pool balances are held together, the vault keeps them isolated from one another and guarantees that no malicious activities can be carried out to steal funds from another pool.

At the same time, the depth of the combined liquidity held in the vault does not impact the price in individual pools but enables some interesting features like Flash Loans and Flash Swaps. Flash loans are uncollateralized loans carried out in a single transaction (loan and repay with interests) while flash swaps allow traders who identify a discrepancy in price between two assets to take advantage of an arbitrage opportunity without the need to hold any of the input tokens.

_____

Balancer Pools

ABalancer Pool is an automated market maker that functions as a self-balancing weighted portfolio and price sensor and is the fundamental building block of Balancer protocol.

What makes Balancer Pools unique is their flexibility. Whereas other protocols have pools with constrained parameters, Balancer allows pools of any composition, enabling developers to build their own custom pools.

Users and teams who want to take advantage of Balancer features have numerous choices when deploying a new pool:

Weighted Pools

Stable Pools

MetaStable Pools

Liquidity Bootstrapping Pools

Managed Pools

Let’s have a look at each of those.

____

Weighted Pools

Weighted pools allow users to implement many different strategies, thanks to their flexibility and configurability.

They are a great choice for pairs of tokens that are loosely or not correlated at all like DAI/WETH. Weighted pools enable users to create pools with up to eight tokens (up to 28 tradable pairs) and assign to each token a customizable weight, as in the 80/20 pool or the 60/20/20.

Weighted Pools allow users to choose their level of exposure to a certain asset, according to their strategies and previsions on the trend of a certain token.

For example, users who are bullish on WBTC will choose to provide liquidity to a 80/20 WBTC-WETH pool, while other users whose strategy is to mitigate impermanent loss could choose a 20/20/60 WBTC/WETH/DAI pool.

WeightedPools are based on an N-dimensional invariant surface, a generalization of the constant product formula:

Starting from the formula above that describes a market maker based on a pool made by two assets, Balancer extended it to manage pools of two or more assets.

How does this work?

Incomparison with the xyk formula, the general formula describes a value function (V) that introduces the concept of weight. V is a function of tokens Weights and Balances are constrained to a constant:

Where V is the constant value, t is the variable ranging through tokens, Bₜ is the balance of token t, W

is the weight associated with token t, normalized so that the sum of all weights is

For example, a three token pool with the following distribution of 20% ETH — 20% WBTC — 60% DAI would look like this when applying the formula above:

The formula above defines an invariant-value surface as illustrated below, such as no matter what trades are carried out in the pool, the share of the value of each token in the pool remains constant.

Each point on the surface represents a Spot Price for each pair of tokens in the pool and is defined by the weights and balances of that pair of tokens only. At any moment Spot Price can be calculated using the following formula:

Where Bᵢ and Wᵢ are respectively the Balance and Weight of the token being sold by the trader (going into the pool),

Bₒ and Wₒ are the Balance and the Weight of the token being bought by the trader (going out of the pool). From this equation, it’s easy to see that if weights are held constant then the spot price changes only when balances change.

In the hypothesis liquidity isn’t added or removed from the pool itself, then the only way balances can change is when trades occur.

When market prices differ from pool prices, traders take advantage of arbitrage opportunities by buying and selling assets and thus rebalancing the pool.

This way the owner of the pool earns fees on trades and saves on the operation connected to fund rebalancing.

PROS

- Highly customizable

- Exposure control

- Numerous trading pairs in a single pool

CONS

  • Slippage grows with the asymmetry of the pool

______

Stable Pools

Stable pools are meant for assets that are expected to trade at near parity. Here the takeaway is to lower price impact as much as possible to allow very large trades.

PROS

- Low price impact

- Batch Swaps are gas efficient as the stable pools are managed by in the same protocol

MetaStable Pools

Metastables Pools are an extension of StablePools and focus on non-pegged highly correlated tokens such as base tokens and their derivatives for example DAI/cDAI.

PROS

  • Good for correlated assets such as wstETH-ETH

______

Liquidity Bootstrapping Pools

Liquidity Bootstrapping Pools take advantage of customizable weights allowing users to define weights that change dynamically as a function of time from a range that span from 1/99 to 99/1 for a pair TokenA/TokenB.

Users can define the start and end weight balance as well as times at which weights are adjusted toward the end value.

PROS

- A change in weight can trigger a Buy/Sell pressure on the pair of tokens in the pool, often leading the price to reach the agreed-upon market price

- Incentivize the widespread distribution of tokens during early-stage token launch

- Enable the team to kickstart token liquidity by employing a minimal starting capital.

_____

Managed Pools

Managed Pools are highly customizable pools, enabling users to implement sophisticated strategies and pools with up to 50 tokens.

PROS

- Highly customizable

Boosted Pools

Boosted Pools allow for deep stablecoin liquidity, allowing traders to swap at the near-parity exchange rate, and boosted rewards for LP coming from trading fees on Balancer plus rewards coming from external protocols to which idle tokens are forwarded.

PROS

- High capital efficiency for LP

- Deep liquidity pool.

______

Custom Pools

Custom Pools are created with developers in mind. Thanks to the Balancer V2 architecture, teams are able to develop their own custom pools, worrying about the logic of their protocol and leaving accounting management to Balancer.

PROS

- Enable teams to easily build and deploy a custom pool taking advantage of Balancer architecture.

______

The Asset Manager

Asset Manager is born with the aim of solving the generalized problem of capital inefficiency of AMM that arose in the past years.

What Asset Manager does is lend tokens to lending protocols in order to improve the pool’s yield, while making sure that the vault always holds a buffer.

The buffer acts like a safety cushion to ensure that the pool does not run out of tokens. When the pool gets close to this event can replenish its balance by calling back tokens from the Asset Manager.

______

Oracles

Oracle is functionality available for certain pools like MetaStablePool and Weighted Pools2tokens and allows the pool to be a price sensor for its tokens.

Oracles can be used to:

- Retrieve the instant price of a token

- Retrieve a Time Weighted Average Price (TWAP)

In v2 oracles have been made resistant to sandwich attacks by using accumulators (see Oracle — Balancer for further details), a feature firstly used in Uniswap v2.

_____

Governance and veBal

Last March, Balancer deployed veBal, the vote escrow token for holders of BAL token.

Since the inception of Balancer, one of the aims of Balancer Labs was to create a protocol that would slowly but steadily shift from centralized governance to distributed governance, bringing Balancer Lab to be one of the many teams contributing to the success of the protocol.

With the veBal Activation Proposal being approved by the Balancer community, the new governance system kicked off and holders of BAL have now the possibility of locking their BAL token in exchange for voting power while liquidity providers can stake their LP tokens to continue receiving liquidity mining incentives, thus encouraging BAL holders to support Balancer in the long term.

Besides this, the new governance system will bring more advantages (see veBal is live — Balancer for more details).

_____

Conclusions

Since its release in 2019, Balancer has improved steadily and proved to be one of the king protocols in DeFi.

Their approach to pools has revolutionized the way index funds are managed and opened to a wide range of possibilities for users and teams when designing new pools, possibilities that were not available before.

Is no surprise that many teams have decided to build their protocols on top of Balancer v2 and as the protocol makes its way toward full decentralization there’s no doubt Balancer will continue to be one of the top protocols in the crypto space.

To summarise the key points:

- Balancer is a community-driven protocol and has recently kicked off the new governance system to go fully decentralized with the vote escrow token veBAL

- Balancer evolution from v1 to v2 brought significant improvements with the introduction of a single vault, improving security and gas cost efficiency and decoupling pool logic from asset accounting and management, thus reducing contract complexity and enabling anyone to easily create and deploy new pools

- Balancer offers different types of pools to fit the diverse needs of builders and users who wish to deploy their portfolio

- Balancer offers even more functionalities and products such as oracles, Asset Managers, Flash Loans, and Flash Swaps.

____________

References

https://docs.balancer.fi/

https://balancer.fi/whitepaper.pdf

What is Balancer Protocol? Everything You Need to Know (cryptopotato.com)

Balancer V1 in Review. When Balancer launched in 2020, we… | by rabmarut | Balancer Protocol | Medium

Introducing Balancer V2: Generalized AMMs | by Fernando Martinelli | Balancer Protocol | Medium

https://medium.com/balancer-protocol/building-liquidity-into-token-distribution-a49d4286e0d4

What is Liquidity Pool (LP) in DeFi? — The Babylonians (theancientbabylonians.com)

Impermanent Loss Explained With Examples & Math — The Chain Bulletin

My Vision for Balancer Protocol — General Chat — Balancer

Balancer Facilitates Record-High Liquidity Bootstrapping Pool For HydraDX | by Stanislav Kozlovski | Balancer Protocol | Medium

Building Liquidity into Token Distribution | by Mike McDonald | Balancer Protocol | Medium

https://medium.com/balancer-simulations/understanding-balancer-pools-c2b877dcc082

https://medium.com/balancer-protocol/calculating-value-impermanent-loss-and-slippage-for-balancer-pools-4371a21f1a86

https://medium.com/balancer-protocol/balancer-v2-generalizing-amms-16343c4563ff#:~:text=The%20main%20architectural%20change%20between,the%20token%20management%20and%20accounting.

https://medium.com/balancer-protocol/vebal-is-live-aeda1ae13e20

3
$ 2.17
$ 2.12 from @TheRandomRewarder
$ 0.05 from @Ruffa
Sponsors of Concave
empty
empty
empty
Avatar for Concave
Written by   9
5 months ago
Enjoyed this article?  Earn Bitcoin Cash by sharing it! Explain
...and you will also help the author collect more tips.

Comments

balancer is really a good baseplate , wen concave baseplate ?

$ 0.00
4 months ago