Burns, Bailouts, and the Balancer Hack

Alan Stacks
7 min readJul 5, 2020

The world of ERC-20 index funds moves fast, and the rise and fall of the first generation of indexes was only a testament to this fact. Let’s start somewhere near the beginning: Statera emerges onto the scene not primarily as an index fund, but as a deflationary coin. It takes its code base from Unibomb, another deflationary token, but Statera puts a twist on the whole thing. First, we have to remember that as a deflationary token, every trade made “on-chain” (i.e. recorded on the Ethereum blockchain) permanently burns a small amount of the tokens traded. Second, we have to understand that the Balancer pool which Statera took advantage of, well, it balances your pool’s assets so that they match some predetermined values. Third, that all these transactions which are done automatically to keep the pool balanced happen on-chain.

This is a very attractive model for a couple reasons. First, the Balancer pool serves to functionally automate the coin burn, so that regardless of individuals trade activity, the supply is automatically reduced, trade by trade. Second, there is a certain inciting mysticism built around the idea of the pool acting as a buttress against price fluctuations. We can take both of these apart in more detail.

Automated Coin Burn:

Personally, I find this is the more attractive of the two propositions. The nature of deflationary tokens has never really excited me. Coin burns themselves have a real purpose, that isn’t the issue. The issue is around the idea of deflation as a value proposition. Anyone with a background in economics will know this is the financial equivalent of smoke and mirrors. Value is decided by a number of different factors, and price by many many more. The idea that deflation in itself provides value is dubious at best (rarity only effects price when value precedes it; consider a merchant in the desert with a thousand liters of water and a single box of saltine crackers, no one would expect the thirsty traveler to fork over his capital for the box of crackers simply because there is only one of them, where on the other side, we can easily imagine him paying a kings ransom for a share of the water (use value here trumps supply in determining exchange value)).

So why is the automatic coin burn attractive? Well in a sense, it changes the game theory entirely. Because coin burn becomes automatic, it can be more easily priced into the tokens value. It doesn’t just result in the empty tokenomics of “if everyone keeps trading, the supply goes down”, it is determinate: “the supply goes down”. While I think this can be extremely attractive in the right context, it still needs to be deconstructed in terms of use value. Regardless of the tokenomic shift, the realities of use value can always catch up. There isn’t a guarantee of price rising in tandem with supply being destroyed, and the “pricing in” we spoke of earlier is strictly limited by the speculative forces already at play. One might even ask the question, why not automate the coin burn in some other way? Perhaps through dapps which burn tokens through use, or designing a liquidity pool (better yet, designing a balancer pool) which has its own burn function separate from the token itself? These could in effect create similar tokenomic advantages which might bolster another project more suited to deflation.

Thanos:

This proposition always rubbed me the wrong way. While yes, the former proposition actually created something, for lack of a better word, “new”, in the realm of tokenomics, the idea of this burn/balance interaction acting as a buttress against price fluctuations is particularly egregious. Nothing about this is new. And worse, nothing about this actually makes sense from an economic standpoint. Yes, there are plenty of cases where the balancer pool would buy Statera and help, in a loose sense, “buy back” a dump. But the problems of economics are never so linear, and it became clear (particularly when STA could be pooled individually) that the Balancer pool can dump STA just as well as it can buy it. The comparison has been made, I think quite understandably, to perpetual motion, or alchemy, as if a simple balancing algorithm could negate the risk in an investment. Economics is never infinite, or self sustaining. Energy cannot be created, only harnessed, and besides, the talk of Thanos being a “whale killer” was put to the test quite early, and the chart speaks for itself.

(I should note here that Stonks came up shortly after, taking advantage of a similar deflationary balancer pool model. Both were calling themselves index funds by this point, and the first generation of ERC-20 index funds had come into their own.)

Then, as quickly as they rose, tragedy also rose to meet them. On June 28th, an exploit was taken advantage of, and the liquidity pools of both tokens were stolen. How did they do this? Well, this gets a bit technical, so let’s try and keep it simple enough for Medium. Basically, someone took advantage of flash loans, doing a number of them instantaneously, to burn the supply of STA in the pool before the pool has communicated with the blockchain to verify the amount of tokens it actually has. At this point, the pool expects the exchanges to have happened 1:1, it still can’t see that the supply has actually been burned, and therefore the balancing trades which should have been making the STA price rise to account for the dwindling supply haven’t taken place. Once the supply of STA is gone, the attacker calls the function to communicate with the blockchain, and the price of STA is recalculated as weighed against all the other assets, meaning the pool assumes the price of STA is astronomical compared to the other assets. This means when the attackers withdraw a small amount of STA’s worth of liquidity, they are able to withdraw a substantial portion of the other funds, which the pool now thinks are equivalent. This resulted in the attacker being able to withdraw the lions share of the STA pool almost instantaneously. Stonks’ Balancer pool fell victim to the same exploit shortly after.

So, was this Balancers fault or STA/Stonks? To a certain degree, neither. This is an unfortunate side effect of DEFI. Not everything is going to work as intended, and real money is on the line. So, in this case, the tokens made the mistake of putting a coin burn in the transfer function of their token. Balancer also made the mistake of not communicating the risks of deflationary intergration as transparently as they could have. At some point during the development of Stacks, Balancer announced they would not be awarding BAL rewards for STA, as the deflationary elements of the token was an attack vector. No one seemed to heed these words (although the discussion of the BAL rewards dominated the conversation in the scene). By this point, our team had already decided to use another model, as the deflationary model already has its own share of issues when it comes to integration, even before this exploit is considered. Remember how the coin burn only happens on-chain? Well centralized exchanges (i.e. big exchanges) don’t do trades on-chain. They do trades on their servers, and move coins on-chain only when needed. This means, besides withdrawals and deposits, a CEX wouldn’t provide any guarantee of a coin burn. This also means you would save a pretty penny on fees if you swing trade on a CEX rather than an on-chain DEX; you can literally circumvent the burn fees. Plus, the obvious: while these deflationary tokens are fascinating economic experiments, they are not ERC-20 compliant, and a lot of platforms would rather not deal with the hassle of adapting to these outliers. Anyways, what I am trying to say is we at Stacks were acutely aware of the problems with integrating deflationary tokens, and took steps in development to preemptively patch these problems. That being said, such a dramatic demonstration of these risks was something we certainly did not expect.

Many people have accused Balancer of being at fault for not fixing the vulnerability, but really, the feasibility of fixing the vulnerability was slim. You can’t just change a smart contract if you don’t like how it works. Balancer could have made a new, adapted pool, and worked in tandem with the STA community to migrate funds as best they could, but they couldn’t have just “fixed it”. This is DEFI, after all, there is no one at the top curating the funds or the contracts. There are many limited and finite actors working in blind association, and sometimes, mistakes are made. The only appeal these actors have is to the contract, to the tech. And so, the funds were stolen, and the mark on the name of ERC-20 index funds made. But neither STA nor Stonks has given up the fight, and Balancer has also offered to reimburse the pooler of lost funds as well. Stonks has made the decision to abandon the coin burn altogether, moving to a fresh contract. This is probably a sensible decision, although it only tends to make the “whirlpool problem” even more glaring (see the white paper). Statera, on the other hand, has decided, in a move which is almost as bizarre as it is clever, to replace the index coin in the Balancer pool to… the Statera Uniswap pool liquidity token. The liquidity token being backed by 3/4’s ETH in a separate Balancer pool as well. So, STA has decided to use the liquidity token for the pool, which is backed by ETH and STA, as an index for the Balancer pool, which is backed in large part by wrapped ETH, but no STA whatsoever. Also the liquidity token, which is backed directly by STA and ETH, is also backed by itself and ETH in a 25/75 split in another pool. This is… well, let’s just say I haven’t finished digesting exactly how this twists the whirlpool problem, but rest assured, it doesn’t solve it. There may be a few more twists and turns in the gyre, but there still is no bottom. But this is best saved for another article.

The public sale for Stacks goes live in three days, and we are looking better than we ever had. We haven’t needed to change a single line of code over all this. Why? Because Stacks was never a first gen token. We want to reinvent ERC-20 index funds, not just make a clone of the old guard.

https://stkstoken.com

--

--