Image by Yam Finance

From $160 to $0.7. How did the governance token of a brand new DeFi protocol explode in value before completely collapsing just 2 days later? A bug in one line of code in a smart contract settled the fate of the launch of Yam Finance. Let’s start at the beginning.

Setting Up The Stage

Yam Finance is a decentralized finance (DeFi) project that combined different features from other DeFi projects, including an elastic supply inspired by Ampleforth, a distribution system similar to Yearn Finance, and a Compound Finance-based governance protocol. Essentially, Yam Finance is a protocol where people can lend and borrow crypto assets without the need of going through a middleman.

The attractiveness of DeFi projects resides mainly in what has now become popular as yield farming. Getting 2% interest on your USDC deposits is lucrative enough on its own, but adding what is essentially free money to each transaction makes DeFi irresistible. This free money comes in the form of governance tokens i.e. tokens used to steer the project through voting. The more popular a DeFi project is, the more the value of its governance tokens grows, especially when they are scarce in circulation. And that is what yield farming is – traders earning on interest rates and governance tokens by utilizing their digital asset holdings. That is passive income at its finest. But, and this is a big but, DeFi is quite risky.

Advertisement

Now, in the case of Yam Finance, the governance token was appropriately named YAM. With a total supply set at 5 million tokens, scheduled to be released in two waves, and no percentage pre-mined, the yield farming potential of the protocol was understandably FOMO-inducing. In less than 24 hours after launch, the protocol was already managing close to $600 million in assets. But it didn’t last long.

A 48-Hour DeFi Frenzy

Aug 11 at 19:00 UTC

YAM Launches

The protocol launches with a total supply of 5,000,000 YAM and a rebase period of 12 hours (8 AM and 8 PM UTC). A key selling point was the fact that no tokens were minted for founders, team, or investors.

The protocol launched with 8 supported pools: COMP, LEND, LINK, MKR, SNX, WETH, YFI, and ETH/AMPL Uniswap v2 liquidity pool, with 250,000 YAM allocated to each pool initially.

In the launch announcement, the founders noted that no formal audits had been conducted on the protocol and that this was a “10-day project from start to launch”, resulting in criticism from people immune to hype.

Close To $600 Million Deposited In The Protocol

In less than 24 hours after launch, YAM Finance is already managing around $580 million in crypto assets.

Aug 12 at 16:30 UTC
Aug 12 at 17:00 UTC

YAM Price Skyrockets

The protocol’s governance token skyrockets in valuation as the DeFi ecosystem explodes in popularity. Major crypto publications spread the success of the project, further fueling the price rally. At its peak, YAM reportedly reached $167.

The Bug

A bug is discovered that ultimately leads to the downfall of the project. The bug itself was just a simple mistake and was found in the rebase function of the contract.

What should have been
totalSupply = initSupply.mul(yamsScalingFactor).div(BASE);
was
totalSupply = initSupply.mul(yamsScalingFactor);.

Sadly, this was enough to make the protocol’s governance feature unusable. The problem was that too many YAM tokens were held in reserve compared to the portion controlled by people. Thus, any proposal would never succeed since the required majority vote couldn’t possibly be reached. A DeFi project that cannot be governed is as good as dead.

Aug 12 at 18:00 UTC
Aug 13 at 0:00 UTC

YAM Crashes

In response to the discovered bug, it took just 6 hours for the price of YAM to plummet from its $160 peak to the now-new $14 all-time low.

Bug Fix

Founders of the project hint at a possible fix, if it could be implemented before the second rebase. Hope is kept alive for about 10 hours as the price of YAM stabilizes around the $14 mark.

Aug 13 at 0:00 UTC
Aug 13 at 8:00 UTC

The Fix Fails

A governance proposal is submitted by founding members in a bid to fix the issue. It is soon discovered that “the rebaser bug would interact with the governance module”, preventing the proposal from succeeding.

YAM Collapses

Yam Finance co-founder Brock Elmore announces the failure to fix the issue at hand, which results in YAM’s market cap completely collapsing. From $14, it plummets to less than $1 in 2 hours.

Aug 13 at 10:00 UTC

A New Hope

As Yam Finance collapsed unto itself, it became apparent that there was something special about the project. People were still working, trying to figure out a way to save it from its impending demise as YAM headed for the zero mark. A plan was presented to the community, where the migration to the new version would happen in two consecutive steps, this time with audited code:

  • Phase 1 – YAM holders burn their tokens via a smart contract and receive YAMv2 tokens in return. The contract used for this process was audited by Peckshield Inc.. At this point, the protocol will not have on-chain governance. Instead, off-chain signature voting will be used.
  • Phase 2 – YAMv3 is deployed, allowing YAMv2 holders to swap their deprecated tokens for the new YAMv3 tokens via a new contract, which will again be audited. On-chain governance is restored.

Close to $115,000 were gathered from 28 contributors on Gitcoin Grants, resulting in a substantial budget set for auditing. At 4:20 PM UTC on 19 August, Phase 1 of the migration plan was executed. The old YAM token became useless, while the new YAMv2 token regained a lot of value – currently trading at around $17.

At this point, the plan is to wait until Phase 2 of the migration plan is fully audited and move on with deployment afterwards. No date has yet been set for the launch of YAMv3, but judging by the short history of the project, it probably won’t take long.

Discussion

avatar