Balancer, AMM and Liquidity Pool

Balancer

Reading time: 6 min

Automated Market Maker

Let us start with a definition and some complicated, scary words, which will become clear by the time you have read the article.

Balancer is a n-dimensional automated market-maker built on the Uniswap protocol (on Ethereum).

Balancer allows anyone to create or add liquidity to customizable Pools and earn trading fees. Those fees come from the action of swapping tokens and whenever someone exits the Pool.

The misterious story of n-dimensional surfaces that is to read in articles on Balancer is in fact about combining up to 16 (in the new version Balancer V2 just released!) different tokens in a Pool. This allows a more dynamic and flexible system, than just having two tokens in the Pool.

The “dimensions” are the number of currencies.

As users start to swap one currency for another, the algorithm will keep the ratios between the different funds within a certain Pool, thus the name “Balance(r)”.

Let us understand how do the different tokens are combined and how does Balance indeed substitutes the market makers in their classical role.

Generalized surfaces

You find yourself in a three-dimensional space, let’s say your office. The floor is the surface embedded in your office, defined by being at the height 0. This is an example of a surface defined by a constraint. It might sound dull, but that how maths sounds when the example is too simple.

Another example: Your desk is a surface, which we can define by specifying its height and dimension. Those constraints are what distinguish that special, 2-dimensional part (your desk) of the 3-dimensional space (the whole office).

A line in the plane can be seen as a one-dimensional surface. (There must be some math involved, sorry.) Remember the xy-plane? Let us denote with l the set of all the points on the plane that satisfy the following constraint:

x · y = 1

This means that the set l is made of all the couple of numbers (x, y), the product of which is equal to 1. For instance, x=2 and y= 0.5, or x=10 and y= 0.1 , since

10 · 0.1 = 1

If you draw a dot for all those pairs in the plane, you will get a line, called an hyperbola, and hyperbolas are beautiful: as x grows, y is forced to shrink in order to keep the balance.

Does this recalls you the demand and offer story? It should. In fact, this is the principle behind the so called Constant Product Markets, like Uniswap.

The deal with Balancer is that it applies the same principle of the hyperbola to many coins, thus moving from a line to a surface, to a 3-d space, to an hypersurface!

If you ever meet the term hypersurface, you don’t need to be scared anymore. In fact, as soon as you put a restriction on a space (of any dimension, that is just a name for the number of coins we are considering), you will get a surface. The different variables (which could be the prices of some tokens) are bounded by constraints, thus building a surface.

I quote from Balancer’s White Paper:

We are aware of one decentralized (read: non-custodial) solution that shares all the fundamental characteristics Balancer was designed to have: Uniswap. This approach was first described by V. Buterin and generalized by Alan Lu. We independently arrived at the same surface definition by starting with the requirement that any trade must maintain a constant proportion of value in each asset of the portfolio.

I do not intend to get too nerdy now (I might do it in following articles), but just give a flavour of what is going on in the white paper. Go back to the example of the hyperbola. Put it in your mind and read the following excerpt (you should need to read it at least 3 times, else this article is way too easy for you).

( … ) We will prove that this surface implies a spot price at each point such that, no matter what exchanges are carried out, the share of value of each token in the Pool remains constant.

So, for the hyperbola, let’s say that at the beginning we have 100 x-coins and 100 y-coins. So we have:

x · y = 100 · 100 = 10’000

Now you want to swap 50 x-tokens for some y’s. With great simplification, we can describe the dynamic: the product x · y must stay constant at 10’000, so there must be 100 y-coins added to the Pool. In total there are 50x and 200y in the Pool:

x · y = 50 · 200 = 10’000


So you bought 100y or 50x. If you want to swap 25x now, they will correspond to 200y, because:

x · y = 25 · 400 = 10’000


Their price has raised! Of course there’s much more to it (up to sixteen variables and more complex dynamics), but this example gives you hopefully a glimp of the logic behind the mechanism.

Liquidity mining

If you have spare crypto tokens lying around, you can join one of the Pools and supply that as liquidity to it. As customers swap tokens, following the Market price, they generate fees which are redistributed among the miners.

Thus, a Balancer Pool is an Automated Market Maker with certain key properties that cause it to function as a self-balancing weighted portfolio and price sensor.

Note that Balancer turns the concept of an index fund on its head: instead of paying fees to portfolio managers to rebalance your portfolio, you collect fees from traders, who rebalance your portfolio by following arbitrage opportunities.

If we open the Balancer website, on the 30/04/2021 we see that the two Pools with the largest market cap are composed as follows:


In both cases there are only two coins in the Pool, but with different weights. The swap fees are also set differently, which will influence the Liquidity Providers as well as the Traders.

If you want to create your own Pool, there are many details that need to be taken into account and it is worth to ask for help, even if the processes are becoming more and more open to the beginner (like me!). Lately, Balancer released a new version (Balancer V2), which allows up to 16 tokens and some more flexibility. It is possible to create Smart Pools, with parameters that can be modified, like change weights, swap fees and add/remove tokens. Note that since Smart Pool operators can, by definition, alter the parameters of the Pool during active trading, all require some level of trust in the Pool creators (beyond the general smart contract risk) – the more parameters they can change, the more trust is required.

Summary

Balancer offers a powerful and user-friendly tool for Liquidity Bootstrapping, alloction of tokens and trading.

Balancer is an Automatic Market Maker based on a generalisation of the idea behind Uniswap. Balancer offers more flexibility and allows up to 16 tokens in a single Pool.

References

Looking for Tokenomics consulting using Balancer? Interested in doing an ICO using new DeFi tools? Contact Us