Liquidity baking in Tezos Granada proposal — how it works

MIDL.dev
8 min readJun 1, 2021

--

by Nicolas Ochem

Liquidity Baking has been submitted to Tezos on-chain governance. Several publications explain what it is (Agora post, TZIP, Nomadic Blog Post), in this blog post we attempt to show the concept under a different light, by explaining what will actually happen when/if it goes live on-chain.

TLDR: the Granada proposal adds a new Decentralized Exchange contract to the Tezos protocol between tez and tzBTC. This contract is “special” because the protocol itself creates tez at every block and adds them to the contract. This incentivizes users to provide liquidity to the contract in order to capture a portion of the subsidy. Liquidity is a desirable attribute of any currency.

The CPMM contract

A Constant Product Market Maker contract is an invention coming from the Ethereum world that provides a Decentralized Exchange between tokens. Such exchanges have existed on Tezos for some time: Dexter, Quipuswap.

In a traditional order book exchange, you place limit orders (essentially posting how much you want to buy/sell and at which price). In a CPMM, you trade tokens by simply submitting how much you want to buy or sell. The contract will ensure that you get a good deal. To achieve that, it stores both tokens in a liquidity pool inside the contract itself.

The liquidity pool is filled by liquidity providers. Anyone can be a liquidity provider by acquiring both tokens and submitting them to the contract at once. In exchange, they get redeemable tokens representing their contribution to the pool. They can withdraw their contribution at any time by returning these redeemable tokens. When they do, they do not get exactly what they contributed: if the proportion of tokens in the pool has changed, they will get back a larger quantity of one token, and one lesser quantity of the other one, than they initially put in. They also receive fees paid by traders in proportion of their contribution.

Uniswap is the most popular of such contracts. In Tezos, the Dexter 2.0 contract is a well-known CPMM contract. It was written by Camlcase and later rewritten and formally verified by Nomadic Labs. This is the contract used in the Granada proposal.

An important property of such contracts is that any trade “moves the needle”. Each time someone trades, they add to one side of the pool and remove from the other. To counteract that, the contract makes it more interesting to do the opposite trade by moving the price a little. This is by design: if you multiply both quantities, you get the same number (hence the name: Constant Product Market Maker). This simple formula creates the right incentive.

See also: A Graphical Guide for Understanding Uniswap.

Decentralized Exchanges work well when there is liquidity in them, meaning, a lot of people have contributed a lot of funds to the contract. When there is a lot of liquidity, most trades are of small value compared to the total amount of liquidity available in the pool, and therefore do not move the price much.

Liquidity is important. As the CFO of Tesla, Zach Kirkhorn, said:

We’ve been quite pleased with how much liquidity there is in the bitcoin market.

Just creating a Decentralized Exchange contract does not automatically guarantee liquidity, because you need people to add funds. It has proven difficult to encourage people to add funds due a lack of rewards. The Granada proposal attempts to solve this problem.

Wrapped Bitcoin

tzBTC is bitcoin, wrapped on Tezos, in custodian fashion.

From Tezos perspective, it is just another FA1.2 token (the Tezos equivalent of ERC20). A reputable Swiss association issues these tokens, and commits to keep one Bitcoin in custody for each tzBTC token that is emitted.

Such a construct is useful because it allows you to exchange Bitcoin and Tezos in a decentralized fashion. When you swap Tezos for tzBTC, you know that the tzBTC token that you receive is ultimately redeemable for a Bitcoin. There are ways to do that without a custodian (algorithmic stablecoins) but it is more experimental.

Granada proposal

Tezos is a self-amending protocol. Twice, the bakers (validators) must vote in favor of a proposal. If they do, at the end of phase 52, the protocol running the Tezos chain will switch over to PtGRANAD. In addition to Liquidity Baking, Granada proposal contains a migration to Emmy* consensus algorithm and a reduction in gas fees.

We will attempt to explain what happens when/if the Granada protocol activates.

As part of the Liquidity Baking proposal, the migration logic for Granada will add a new contract to the chain storage, at address KT1TxqZ8QtKvLu3V3JH7Gx58n7Co8pgtpQU5.

This contract is a Constant Product Market Maker between tez (the native token) and tzBTC, as described above. It is similar to Dexter 2.0, but with a few differences. The trading fee is 0.1% instead of 0.3% for Dexter contracts.

Initially, the CPMM contract is almost empty. It contains a tiny amount of tez and tzBTC to set the initial rate. It is very similar to what you would get by initiating a new Dexter pair with no special help from the protocol.

Anyone could have pushed such a contract to the chain. But then, at next block, something magical happens. The protocol is amended in such a way that the tez balance in the pool will increase by 2.5 tez at every block.

Wait, what?

This is not what you would expect. Everyone’s gut reaction is that this is a poor separation of concerns and a violation of the defi layers. Normally, the base layer is a neutral world computer. Smart contracts and decentralized exchanges live on this substrate. Why is a contract in particular getting special treatment? To answer that, let us see what happens if the protocol activates.

Protocol-funded CPMM

Alice, a liquidity provider, was eagerly waiting for the protocol activation and had already bought some tzBTC. She adds 10 tez, plus 10 tez worth of tzBTC in the liquidity pool. In exchange, the contract allocates some redeemable tokens to her.

At next block, the pair contains 12.5 tez and 10 tez worth of tzBTC. From the contract’s point of view, Alice provided 100% of the liquidity and therefore 100% of the trading fees go to her. And if she withdraws from the pool at this stage, she would earn 25% returns in the 10 tez she added as liquidity (thanks to the 2.5 tez given by the protocol). Sweet!

5 tez per minute? Sign me up

That is not what will happen however, because there will be a lot of Alices eagerly waiting to provide liquidity to this contract in anticipation of lucrative rewards straight from the protocol. So, at block +1, it is likely that the pool will have a lot of tzBTC and tez, from many liquidity providers.

Enter Bob the trader

At next block, since the procotol added 2.5tez, it made the tzBTC/tez pair artificially more expensive than on centralized exchanges. Bob, realizing the opportunity, will acquire tzBTC, send them to the contract and get cheap tez. By doing that, he will remove some tez and add more tzBTC to the pool, “rebalancing” it and moving the price closer to its external value.

Few blocks later

The protocol keeps inflating the tez balance in the CPMM by adding 2.5 tez per block, slightly increasing the tzBTC price in the contract. In response, more Bobs (arbitragers) will keep acquiring more tzBTC and trading them for tez.

Meanwhile, more Alices provide liquidity by providing a combination of tez and tzBTC. Shall Alice remove the liquidity, she will get more Tez back than what she put, because the protocol selflessly added extra without changing her stake in the pool!

This makes it interesting for Alice to be a liquidity provider: she would get more rewards than if she was baking or delegating her tez. This also brings the system to an equilibrium: when 1/16th of total tez are providing liquidity, the liquidity provider rewards are comparable to baking rewards. Past this point, the 2.5 tez per block will be shared between so many liquidity providers that it will become less interesting.

A combination of liquidity-adding Alices and arbitraging Bobs cause the tzBTC/tez price to move closer to the BTC/tez price on centralized exchanges, and stabilize at this value.

It also causes a lot of tez and tzBTC to be added in the liquidity pool over time. By extension, a lot of BTC will have been deposited at the Bitcoin Association Switzerland, with their representation minted on the Tezos network as tzBTC tokens, increasing the amount of value circulating in the Tezos network.

The tez/tzBTC pair will also be extremely liquid: since the CPMM contract has so much value in it, it increases the amount of tez someone can buy or sell without paying a large premium (slippage).

Absent this protocol update, achieving such a result is hard.

Inflation

This proposal results in 2.5 additional tez being created at each block than would otherwise have been. These rewards are not taken away from bakers: they receive the same amount than before. This increases the supply of tez overall.

To counteract this increase in supply a little, 0.1% of every trade through this contract is burned by transferring it to the null implicit account, instead of being passed as a fee.

No one stands to benefit or lose from this increase in supply in particular: it affects everyone. The assumption is that the effect of this will be counterbalanced by the benefits of introducing the Liquidity Baking mechanism.

Phase out

This is an experiment: it is written in a way that will phase out in 6 months without any intervention. To continue the experiment, another protocol upgrade vote will be needed. There is also an escape hatch: bakers can raise a flag for the experiment to stop sooner. If enough bakers do, the 2.5 tez liquidity rewards per block will stop flowing.

A later protocol upgrade may switch to a different pair, or a different contract. For this first experiment, the choice has been made to favor tzBTC and this specific contract code, because it is seen by the proposers as the safest and most obvious choice to prove the usefulness of the mechanism.

Vote for liquidity baking

Cryptoeconomics is all about creating the right rules so economically rational actors will contribute to something useful. By explaining what happens when this upgrade kicks in, we hope to have demonstrated its usefulness: it creates a liquid pair between tez and a very liquid asset (Bitcoin).

For Tezos to win, it needs liquidity. Liquidity will naturally happen when the world realizes the power of Tezos, but the world may never see the power of Tezos until it is more liquid. We can force this to happen by giving a nudge at the protocol level.

This is the true force of Tezos: using the governance model to a good outcome. It is tempting to limit this governance model to changes in the base layer but this is missing the point that Tezos is competing in a crowded ecosystem of interesting ideas, and blockchain is winner-take-all.

Thanks to Sophia Gold for proof-reading.

We are MIDL.dev: we provide Tezos baking as a service as well as other services for proof-of-stake blockchains. We provide recommendations on on-chain governance proposals for the benefits of our customers and the community.

--

--