Understanding Balancer Protocol from 0 to 100

arnau ramio
19 min readSep 4, 2020

Original Post (Spanish) = https://criptoblog.tutellus.com/entendiendo-balancer-por-completo/

Without a doubt, the growth of the DeFi ecosystem in recent months has been crazy. This has made many begin to see these financial protocols as a speculative bubble, and although this scenario is possible, I do not think it is unjustified. DeFi has come to stay, since for the first time we are in front of a technology capable of bringing financial services to anyone in the world, without friction or intermediaries, completely transparent and that grants equal opportunities regardless of your site of birth. And even if there may be a “bubble” as happened in 2017 with the ICOs, DeFi will continue to move forward until it becomes even one of the most important Blockchain ecosystems.

In today’s post we will delve into Balancer, a decentralized exchange that has been a protagonist in the growth of DeFi during these months and that has managed to replace Uniswap as the leading platform in atomic swaps between Ethereum tokens. We will not stay on the surface, but we will try to tear the protocol to pieces and understand why it is so important and disruptive.

Balancer is now the protocol with more liquidity

DEX’s

Decentralized Exchanges are born to solve a latent problem in the crypto world; the dependence on centralized exchange that generate friction, raise costs and loss of time. The idea was to create a decentralized platform where you could trade your assets without losing control over them, and with minimal commissions and times.

The first DEX to gain traction was Uniswap, a protocol that acts as a decentralized exchange on the Ethereum network that offers “exchange transactions” or “swaps” through liquidity locked in on-chain pools, contributed by users seeking to generate a profit from their assets. A characteristic of these pools is that they always contain the same value between the two deposited tokens (50% ETH + 50% ERC20 // 50% ERC20 + 50% ERC20). Swaps are achieved by operating against these pools, which also have an automatic market making system that manages to keep the pool’s value balanced, even with changes in the value of the deposited tokens. This allows the creation of an exchange system capable of determining the price of an asset in a decentralized way, without intermediaries or purchase-sale order books. Uniswap was really the first big innovation in decentralized exchanges, and it showed us a new way of understanding market making. To know more about Uniswap I recommend you read this post.

After two years leading the market, Uniswap became second on the list, surpased by a DEX called Balancer. This project was born with the goal, similar to Uniswap, to allow AMM (automated market making) in order to generate income through those unemployed assets that are not generating performance. In other words, as with Uniswap, liquidity providers can deposit their assets in existing pools to be able to offer swaps to traders that compensate providers by generating a return on their assets through fees. In Balancer they can even convert their entire investment portfolio into a pool, since it allows you to create all kinds of pools; with more than 8 tokens and with a more interesting distribution than Uniswap, since you are not obliged to maintain a 50% ratio between two tokens. Without a doubt, there was a great demand to be able to provide liquidity in a flexible and independent way natively in a protocol, and Balancer has been able to take advantage of it.

In short, Balancer is a multi-token protocol that allows automatic market-making with the possibility of creating an infinity of pools, with different proportions between tokens, number of tokens and with fees that can range between 0.0001% and 10%.

Pool with 8 tokens with a 13% weight each

BALANCER AND HIS INNOVATIONS

Balancer’s mission is to offer a financial protocol that allows in a flexible and decentralized way to provide programmable liquidity, and through this, offer instant on-chain swaps with efficient gas costs to the entire ecosystem.

At first glance it may seem that Balancer is nothing more than a Uniswap with the possibility of creating pools with more tokens and with ratios between tokens different from 50/50, but if we study the protocol we’ll see it is much more than this.

In traditional finance we find the so-called “index asset managers”; Indexed investment funds that keep the distribution between the different assets constant. Here investors are charged a commission not only for participating in the fund, but also for the rebalancing between assets that are updated by asset managers. Balancer has completely reversed the economic logic of these funds. Now with Balancer, not only do you not have to pay fees for participating in the pools acting as a liquidity provider, but you also generate income through fees for achieving this rebalancing. They pay you to participate in a protocol with a natively integrated asset management function. This is because the protocol sells part of its assets and charges a commission for the sale in order to rebalance the proportions between the tokens.

This rebalancing takes place through arbitrage, since investors are incentivized to trade pools where the price has risen or fallen to areas where it is profitable to trade and “rebalance” them. This allows the pools to charge commissions for these trades and therefore generates returns to the liquidity providers, in addition to allowing the portfolio to be rebalanced again.

In some way Balancer has completely decentralized the concept of market-making, not only because of what we have commented previously, but also because you always have the option of turning your entire portfolio into a new pool. In other words, you can choose the distribution between tokens that you prefer and use Balancer to rebalance those proportions, in addition to charging fees for doing so. Just amazing!

So far we are not taking into account Balancer’s contribution to the ecosystem either, since it acts as a kind of “sandbox” that allows us to innovate and investigate in relation to pools with unequal proportions and fees and thus find solutions to problems that we have not yet found.

PROTOCOL INTERNAL PROCESS

At the protocol level, the operation to determine a price for swaps is very similar to Uniswap. The mathematical framework is more complex because it must calculate prices in pools with proportions other than 50/50, also maintaining the percentage balance between the tokens.

In Balancer we can find two users, liquidity providers and traders. The liquidity providers are those who act as owners of the pools, and who contribute their assets to them to offer efficient and cheap swaps to traders. They generate a return on their capital through fees, in addition to having a remunerated asset management service since you can participate or create all types of pools, with completely different tokens and distributions. On the other hand we have the traders who “use the pools” as an exchange service to make swaps between tokens. They can also use the protocol to generate arbitrage opportunities. One type of “trader” that makes use of pools could also be smart contracts that use Balancer as a liquidity provider to be able to carry out their previously programmed functions.

When a trader makes a request for a swap, the protocol calculates the price with a system similar to the one used by Uniswap, although not 100% the same. In other words, the basic criteria for determining the price do coincide: the liquidity of the pools and the quantity requested. The more the pool is stressed, the more slipage (price movement) there will be.

Let’s analyze the first difference. In Uniswap the calculations to determine prices are easier since each pair of tokens has its own pool. In Balancer, however, we can find the same pair in many different pools, all of them with different liquidity, different number of tokens and different distribution of those tokens. That is why Balancer integrates an off-chain price optimizer known as SOR (smart order router). It consists of a routing that, depending on the pair of tokens that you want to swap and the amount, searches among all the pools with that pair and thus provide the best possible price. This “best price” may imply using several pools and even swaps with different amounts depending on the pool.

Let’s take an example; imagine you want to swap 3 ETH for LEND. At the moment you make the swap request, the protocol will use the SOR to search among all the pools that contain ETH and LEND which is the combination to obtain the best price. The result could be to swap 1ETH in pool “X”, which contains ETH, LINK, LEND and MKR; make a swap of 1.5ETH in pool “Y”, which contains LEND and DAI and a last swap of 0.5ETH in pool “Z”, which contains LEND, DAI, USDC, SNX and KNC.

This routing, which will be available on-chain in future updates, is truly amazing. It allows you to use several pools to prevent slipage from harming you and thus get very competitive prices. With this logic, Balancer prices should be the cheapest in the ecosystem, and although this is sometimes the case, it has a small problem: interacting with a pool implies executing a smart contract on the Ethereum network, which implies paying a gas fee. This often means that the best option is not possible due to the increased cost of gas, which the SOR also takes into account. This also creates imbalances and therefore arbitrage opportunities. I’ll explain this in more detail:

As the gas fee increases, the protocol cannot use all the available pools to get the best price, so it will generally use the one with the most liquidity and perhaps a few more. This causes the prices established between specific pairs to be different between the different pools, causing part of the value that the trader has left behind to end up in the hand of an arbitrage operation that will seek to rebalance the prices between pools. This is normal when there are changes in the prices of assets, but they are also a sign of inefficiency when it happens due to imbalances of the pools not generated by changes in the value of the portfolio tokens.

The ideal case (perhaps possible in the future) will be to have gas costs so minimal that a trade can make use of as many pools as necessary, thus achieving that the exchange price between two tokens moves exactly the same way between all the pools that contain that pair.

UNEVEN POOLS

A particularity of Balancer, as we have seen during the post, is the possibility of creating pools with several tokens and with different proportions. In Uniswap for example, there is only one pool for each pair, and it contains a 50/50 ratio between the two tokens.

We are going to dedicate a few lines to investigate possible use cases in addition to commenting on the consequences that these types of pools can have.

Boostrap liquidity pools

This concept is for me one of the most interesting points in Balancer. One of the most disruptive use cases of Uniswap was the possibility of generating markets from scratch, you no longer had to go through an exchange to give liquidity to your own token. Thanks to decentralized market making and the ability to price tokens without an order book meant that you could create a market for your own token with almost no friction.

Although it sounds very great, this use case had some limitations, the most important being the fact that in order to create a pool of your own token you had to put in ETH or an ERC20 the equivalent of 50% of the value you wanted to deposit, doing this unattractive option for those without funds. In fact, if we compare it with an alternative to classical financing of an ICO, it is paradoxical that you need half the capital that you would like to obtain during the ICO.

At Balancer you can now use pools with ratios as radical as 95/5. 95% of the value in your own token and 5% in another token such as ETH or DAI. It allows you to give liquidity to your token without having to have many resources. And every time the token ratio varies it means that you are losing your own tokens in return to ETH or DAI. Just great for ICO’s or STO’s or even projects that simply seek to give liquidity to their own token, which is good; It benefits them not only because it makes the token more attractive, but also because it generates a return on its capital through the fees.

For example, many founders or advisors usually receive large amounts of tokens on the project they have developed. Obviously this puts them in a “skin in the game” situation where they do not want to sell everything and collapse their price, since they are incentivized to make the price increase and create a bright future for the project. In this case, these “whales” can contribute their tokens in unequal Balancer pools, first to give more usability to the token they hold, second to rebalance their portfolio towards more solid tokens such as ETH or DAI without damaging their market valuation and last to generate a return on their capital in the form of fees.

Bullish Portfolios

It is often advisable to diversify your investment portfolio, although there are also cases where you bet on a specific project. These investors generally do not have an incentive to provide liquidity in Uniswap, since that implies that they have to deposit 50% of the value in another token that they may not have, in addition to assuming the risk of losing exposure to the token they hold.

With the unequal pools of Balancer, now these investors can generate fees from their capital without losing exposure to their token, they can simply participate in pools with distributions of 90/10–95/5.

Impermanent loss

The concept of impermanent loss is of vital importance when it comes to becoming a liquidity provider, and it is often frustrating to see how your capital has decreased despite receiving income in the form of fees. It basically refers to the loss of value of your assets when you invest in liquidity pools compared to when you simply hold it.

To be clear, since it is a question that I am asked very frequently, I will put an example to understand well when it happens and why, using as an example a pool in Uniswap.

Let’s take the case that I want to deposit in a Uniswap pool 10 ETH and 1000 DAI which represents 1% of the pool, since it contains 1000 ETH and 100,000 DAI. The first conclusion is that the price of 1 ETH = 100 DAI since one of the Uniswap conditions is that the pool must have a 50/50 ratio. Now let’s imagine that the price of ETH has changed to 120 DAI (a 20% appreciation); now the protocol must make use of its native asset management to retrieve the 50/50 distribution between the two tokens;

- ETH = 910.2871

- DAI = 109,540.45

As we own 1% of the pool, it means that we now have the right to recover a total of 9,128 ETH and 1,095.4 DAI. To better understand if we have been winning in the operation, the most practical thing is to transform everything into DAI, since it is a stable token and will allow us to compare the initially deposited value with the withdrawn value. Making the change we have a total value of 2190.09 DAI, and if we look at how much we initially deposit the total equals 2200 DAI. In other words, we have stopped earning 9.1 DAI for having participated in a liquidity pool.

Of course, this is due to rebalancing, which causes that little by little you are losing exposure in the tokens that are revaluing. The first conclusion then is that if you are long-term in a token, the best time to use that asset to provide liquidity is during bear markets, since when the price rises you lose exposure, but when the price falls, you gain exposure. This loss in value is represented by the following graph, which provides us with the following information:

  • A x1.25 of the price results in a loss of 0.6% compared to holding.
  • A x2 of the price results in a loss of 5.7% compared to holding.
  • A x4 of the price results in a 20% loss compared to holding.
  • A x5 of the price results in a loss of 25.5% compared to holding.

Now let’s look at this concept applied to Balancer pools:

The concept of impermanent loss is also found in Balancer, although in a much more flexible way. To expose this concept we will refer only to pools with 2 tokens, although it is also applicable to pools with even 8 tokens.

Thanks to the possibility of creating unequal pools, this means that the impermanent loss can be higher or lower depending on the proportions. Let’s see the graph:

Previously we have seen that a 50/50 pool where we have an increase of x5 in the token valuation the impermanent loss is of 25.5%, but in 95/5 pools this loss is reduced to 3.88%, 6.5 times lower. In other words, those investors who have great confidence in a token can maintain a very high exposure while generating fees at the same time.

Balancer pools are much more flexible and better suited to the specific needs of each liquidity provider. In some way this protocol is truly decentralizing the market-making.

Slipage en el precio y APR (Anual Percentage Rate)

The concept of slipage consists of how much the swap price can vary depending on the stress that the pool is assuming. That is, if I want to swap 1ETH per DAI and the pool has a very liquidity, if 1ETH = 100DAI, surely the swap will bring me 100 DAI. Now, if we want to swap 1000ETH, surely we will not receive 100,000DAI, since we will have put too much stress on the pool and it will be charging a higher exchange price.

Therefore, the most efficient pools in terms of price slipage are the 50/50 pools. We can demonstrate it by means of the following graph:

Uneven pools cause a higher slipage, resulting in less volume traded and therefore a lower ARP or annual return. This could be a disadvantage for Balancer compared to Uniswap as long as gas costs remain so high. Since the SOR cannot use many pools at the same time, on certain swaps Uniswap could be offering a better price.

Swing-Trading y Pool con altas fees

Another peculiarity of Balancer is the option to manipulate the pool fees. Now, this is only possible in “private pools” where there is only one owner and he has the power to make constant changes in the operation logic of the pool. The “public pools” or open pool, where anyone can invest, it’s aspects cannot be modifies.

The initial premise is very logical: the higher the fees of a pool, the less frequently you will receive swap requests and therefore the less fees or returns you will be able to generate from your assets. For this reason, the times in which these pools are to be used is when due to imbalances in the prices of the pools -generated by variations in the prices of the underlying assets- allow you to offset the pool fee.

Let’s take an example; 1ETH = 100DAI, and this is the price you expect to get when you swap. A pool with a 10% commission will only be used when due to pool imbalances it offers a swap where 1ETH = 110DAI. From that price there are incentives for arbitrage positions or even traders to swap in this pool.

As long as the price of ETH remains between the areas where buying / selling is profitable, there will be no arbitrage operations that will rebalance the portfolio.

In this image, instead, the price has been placed in areas where both buying / selling have been profitable. It is in these areas when trades enter that allow the portfolio to be rebalanced and to move ETH prices again to generate buy / sell opportunities.

As we see in the previous image, this changes when the price moves considerably, since it is from that moment when the trades and arbitrage operations begin to be profitable. In the following image we can see how the pool with fees of 10% — the one that is closest to a holding position — is less affected by the impermanent loss. It has even been more profitable to maintain pools of 10% compared to doing purely holding.

As we can see, Balancer pools offer a lot of possibilities and therefore different investment strategies. Choosing a pool with high fees allows you to rebalance by buying low and selling high, something very attractive. In contrast, the pool is much less active and therefore generates a much lower return. On the other hand, you can choose pools with very low fees, which will generate a huge volume traded (both for trades in search of a good price and for arbitrage opportunities to compensate for variations in price), although you will also generate less income per trade and you will see your portfolio most affected by impermanent loss.

A pool with high fees could be seen as a substitute for conventional index funds with asset management strategies where the portfolio is only rebalanced when significant variations of x% are reached. In other words, the pool will allow the portfolio to fluctuate until arbitrage operations do not arrive due to strong fluctuations in assets.

IN WHICH POOL SHOULD I INVEST?

This pool is a great option because, being stable tokens, you are left out of suffering impermanent loss.

This pool is really interesting since it has in its portfolio some of the most traded tokens in Ethereum, in addition to being very efficient in relation to the capital contributed. Note that in this case we can suffer losses due to impermanent loss if large increases in the price of ETH take place.

This pool, in addition to being highly profitable, has a 50/50 distribution, which makes it very attractive when it comes to swapping thanks to its efficiency in price slipge. If we want to be more aggressive, we can select the 80/20 pool, although this has a 1% commission, which despite making it more attractive, discourages making swaps due to its cost per transaction. This pool is also interesting to take advantage of BAL falls to accumulate ETH.

This pool with disproportionate returns is a good option if we want to participate in the latest Liquidity Mining craze and take a riskier position.

MakerDAO is one of the most important projects in the DeFi ecosystem, and has also historically been one of the most profitable pools. That is why it could not be missing from this Top 5 of pools in Balancer.

LIQUIDITY MINING

Before ending the post, the liquidity mining part could not be missed: basically an incentive system that remunerates users for providing liquidity to the protocol with the protocol governance tokens

Balancer was among the first protocols to go public with this incentive strategy, which certainly makes a lot of sense. The competitiveness and efficiency of a DEX rests above all on the liquidity it has available. The more liquidity the more users can enjoy cheaper and more efficient swaps, which increases the daily volume in the protocol, which in turn increases the profitability generated by the protocol through fees, which again encourages other users even more to add more liquidity. This virtuous circle has started thanks to another incentive that is the issuance of BAL governance tokens, which have been the ones that have pushed the wheel so that it can turn on its own.

This has been one of the reasons that has allowed Balancer to grow exponentially and become the absolute leader in decentralized swaps. It is also interesting to see its real operation, since as we have seen there are many options regarding the creation of pools in Balancer, but not all of them provide the same “value” to the protocol, and that is why their compensations in BAL are different. That is, a pool with a fee of 0.001% and with highly traded tokens such as ETH and DAI, will provide more efficiency and value to traders than a pool with a 10% fee with very little traded tokens.

The topic of liquidity mining is very extensive so we have dedicated this post and this other to develop it. I recommend you read them if you want to delve into its operation.

CONCLUSION

After a good reading I think we can say that Balancer is not simply a Uniswap 2 that only allows pools with different proportions. Rather it is a full-blown disruption that decentralizes for the first time and gives the possibility to any user to participate in “asset management index funds” without paying commissions. In fact, it is the opposite: you generate returns in the form of fees for doing so.

Balancer will undoubtedly be the protagonist in the coming months as it serves as a “sandbox” to test and design new investment strategies, highly varied thanks to the possibility of manipulating many technical aspects of the pool (number of tokens, their distribution, fees…).

There are more and more opportunities to become a liquidity provider and generate returns to our cryptoassets. A very important limit that I saw in Uniswap is the high possibility of losing part of the return generated by the asset that you hold in a bull-market due to the impermanent loss. Now with pools with high fees and unequal proportions (90/10 or 95/5) this scenario is completely different.

If you want to go deeper into Balancer and learn more investment strategies, also seen in a practical way, participate in our training courses, both in the Blockchain Master and in the DeFi Bootcamp. Decentralized finance is generating investment opportunities everywhere, missing this train could be very expensive! ;)

REFERENCES

--

--

arnau ramio

Blockchain-Business Developer & DeFi Manager. Co-Founder & COO at Themar Solutions and Co-Founder of Learningheroes.com