Introducing Balancer V2: Generalized AMMs

Fernando Martinelli
Feb 2 · 6 min read

Balancer v1 exceeded our expectations by evolving liquidity provisions and attracting a robust, engaged community. Today, we’re proud to share Balancer V2, an upgrade which will bring us closer to Balancer’s vision of being the primary source for DeFi liquidity.

The core tenets of Balancer V2 are security, flexibility, capital efficiency and gas efficiency. These highlights include:

  • Protocol Vault for all Balancer pool assets
  • Improved gas efficiency
  • Permissionless, customizable AMM logic
  • Capital efficiency through Asset Managers
  • Low gas cost and resilient oracles
  • Community-governed protocol fees

Protocol Vault

The main architectural change between Balancer V1 and Balancer V2 is the transition to a single vault that holds and manages all the assets added by all Balancer pools.

Balancer V2 separates the Automated Market Maker (AMM) logic from the token management and accounting. Token management/accounting is done by the vault while the AMM logic is individual to each pool.

Balancer V2 separates the AMM logic from token management and accounting

Gas Efficiency

In Balancer V1 — and all AMMs we are aware of — trading with two or more pools is gas inefficient because users have to send and receive ERC20 tokens from all pools.

With Balancer's new Protocol Vault, even though trades are carried out in batches against multiple pools, only the final net token amounts are transferred from and to the vault, saving a significant amount of gas in the process.

Since only final net amounts are transferred, arbitrage trades are also significantly easier. An arber who has no tokens but detects a price asymmetry between Balancer pools could trade DAI for MKR in pool 1, MKR for BAL in pool 2 then BAL for DAI in pool 3 and end up making a profit in DAI.

Balancer v2 executes many trades at once with the Vault doing a single settlement

Balancer V2 allows users to hold internal token balances. This is extremely useful for high-frequency trader efficiency.

For example, if you trade token A for token B but know that you will trade back B for A in a few hours, then you probably don’t need to take delivery of B after the first trade. Balancer can keep both tokens in the vault which may be used for the next trades, avoiding any ERC20 transactions altogether. We expect to see aggregators and other curators using Balancer’s internal balances to be able to provide trades with the lowest gas costs to their users.

Customizable AMM Logic

We are in the first inning of automated market makers and aspire to be the go-to platform for developers, traders, and liquidity providers. In 2020, there was an influx of use-case specific AMMs with different trade-offs optimizing for different goals. This trend is very likely going to be even stronger in 2021.

Balancer V2 pioneers customizable AMM logic by creating a launchpad for teams to innovate with different AMM strategies without having to worry about low-level token transfers, balance accounting, security checks and smart order routing. With Balancer V2, this all comes out of the box.

Asset Managers

AMMs have been extremely successful in 2020. However, a lack of capital efficiency arises as most of the assets in an AMM are not actually used at any given time. Balancer V2 has a simple yet powerful feature that addresses this and revolutionizes the way AMMs are designed: Asset Managers.

Asset Managers are external smart contracts nominated by pools that have full power over the underlying tokens the pool has deposited in the vault.

Asset Managers make Balancer V2 pools more capital efficient

Low Gas Cost and Resilient Oracles

Balancer V2 will include oracles that are resistant to sandwich attacks using accumulators — as pioneered by Uniswap V2. In addition, dApps will be able to query prices with minimal gas costs and without having to store past accumulator states. We plan on offering two types of prices that can be queried with low gas costs:

  • Instant: A more up-to-date price but less resilient to manipulation
  • Resilient: A less up-to-date price but more resilient to manipulation

Choosing a price type will vary depending on each use case. For example, lending protocols will likely rely on the resilient price while prediction markets could use the instant price.

Governable Protocol Fees

As Balancer transitions towards a community-driven protocol, Balancer V2 implements three different types of protocol level fees that are controlled by governance (BAL token holders):

  • Trading fees: A small percentage of the trading fees paid by traders to pool LPs.
  • Withdrawal fees: A small percentage of any tokens that are withdrawn from the Balancer Protocol Vault (trades not included). Moving liquidity between Balancer pools does not incur this fee.
  • Flash Loan fees: A small percentage of assets that are used for flash loans from Balancer’s vault.

Trading fees and withdrawal fees will be turned off at inception, while the Flash Loan fee will start at a small value to ensure there is always a cost of capital to create a flash loan on Balancer. At first, all protocol fees will be kept in the vault. It will be up to Balancer’s governance to decide if and how these fees are used.

V2 Recap

We are incredibly excited to ship Balancer V2 and continue making the AMM space:

  • Secure — Extreme care was taken in guaranteeing the vault architecture keeps internal balances isolated among pools. Core contracts will undergo formal verification.
  • Simple — all interactions with Balancer V2 will be done through one single access point: the vault. Only one token approval will be necessary for users to trade or invest liquidity in any Balancer pool.
  • Gas efficient — trading against both standard and stable pools will cost a little over 100k gas, which is on par with Uniswap V2. Trades will cost even less if internal balances are used. Trading with many pools at the same time only marginally increases the gas costs.
  • Capital efficient — pools have full control over the underlying tokens they add to the vault. This opens up vast design space to improve capital efficiency and for other use cases like using underlying tokens to vote.
  • Flexible — Balancer welcomes other teams to innovate on top of V2, creating a thriving ecosystem and network effect. Grants and bounties will be given to contributors who create new successful pools.

What’s Next?

Internal audits are underway, and Balancer V2 is expected to launch this March.

However, as the code is nearly frozen, a handful of projects have reached out to express interest to build on V2 before the official launch.

We want to engage with ambitious teams that can leverage Balancer V2 to reach a broader audience. If you think Balancer V2 is a good fit for your project, please reach out to us to become part of our V2 launch partner program. Launch partners will have early access to our repository and documentation so they can start building on top of Balancer V2.

This launch is a step towards Balancer’s larger vision to become the primary source of DeFi liquidity.

We look forward to making 2021 the best year for DeFi composability yet!

Follow Balancer

Twitter | Discord | Website | Dashboard

Balancer Protocol

Automated portfolio manager and trading platform.