staking in deFi
| first passes serieshow to approach learning deFi
A partner that I worked under at an asset management fund where I was a financial analyst told me that learning finance was “50% vocabulary”. Many of the core concepts aren’t that complex once they’re broken down but the language used to describe them can be quite confusing. So far, my impression of decentralized finance is the same.
Not only is the def deFi space complex but it’s also changing constantly. It’s hard to know where to start. I think the best place to start is staking. If you can attain a solid understanding of this concept, then many of the other pieces of the deFi puzzle become more intuitive - yield farming, synthetics, stablecoins etc. Investing time in understanding staking relatively deeply will give you a higher return on subsequent learning investments. Accordingly, this post will lay out the fundamental ideas around staking in deFi.
the philosophy of deFi
It’s useful to have the philosophy of this movement in mind as we go through staking and some of its recent applications.
An idealized version of deFi would exhibit the following characteristics, according to the Defiant 1 : non-custodial (you always have control of your assets, there is no bank vault to which you could be denied access), open (anyone can participate), transparent (the logic of these applications is open source and forkable), decentralized (in this context, that means that the core functionality of the application is hosted on a blockchain).
Interestingly, the Defiant leaves out the idea of privacy. There are a number of angles to privacy - anonymity, pseudonymity, or simply a need-to-know and limited-use approach to personally identifying information. But for the purposes of this, they can be lumped together.
Its important to not get myopic about decentralization here. At the end of the day, what we’re really aiming for is more sovereignty rather than decentralization for decentralization’s sake. And like decentralization, privacy is an integral component of sovereignty. So while the tenets of deFi are a great guidepost for what needs to be built, they aren’t the ultimate goal, imo, and shouldn’t be treated as such.
the origins of staking
Like many great innovations, before DeFi, staking was a solution laying around looking for more problems to solve. It came into existence via the proof of stake consensus mechanism - an alternative to the proof of work mechanism that Bitcoin uses (and the thing that’s led to many of the recent debates about Bitcoin’s energy consumption).
In PoW, miners compete in a race every x minutes (10, in Bitcoin’s case) to solve a computationally intensive puzzle. The first person to solve the puzzle is the one who is allowed to determine what the next block of the blockchain will be.
In PoS, miners simply take turns determining what the next block of the blockchain will be (they’re selected via a semi-random algorithm). In order to be eligible for this turn-taking process, a miner has to commit funds to a smart contract. They still own the funds, but they temporarily give up control of them to the contract that enforces the mining process. Typically, the more funds you’ve committed, the greater your chances of being selected by the semi-random algorithm and actually getting to pick the next block. The idea here is that the more funds you have at risk, the more trustworthy you are and so you should be prioritized in the who-gets-to-pick-the-next-block selection process. If a miner tries to do something nefarious while mining, she will be penalized by that contract and lose some or all of the funds she’s committed to that smart contract. This “commitment” is what’s known as a stake and is what gives the consensus mechanism it’s name.
So, in summary, staking simply means committing some crypto-asset to a smart contract. That’s it. It started out being used to keep miners honest about their behavior on a network. DeFi took this simple idea to an entirely different level as we will presently see…
staking for lending and collateral
One of the first and most basic applications of staking in decentralized finance had to do with lending. It’s pretty straight forward: There are no banks in deFi so staking is a way for lenders to commit funds and for borrowers to commit collateral. Generally speaking, lending works more or less the way one would expect it to if coming from a tradFi background. It might be helpful to think of staking as roughly analogous to depositing, in the case of the lender.
tokens distributed to the staker of assets : “liquidity provider (lp) tokens”
When you stake something, you give up control of that asset (even though, you still officially “own” it). And there’s not really any such thing as paperwork in deFi. So once you’ve staked those assets, what do you get in return to prove that are you are their original owner? The answer is “liquidity provider tokens” (or sometimes just “liquidity tokens”). Think of them as deposit slips that can later be used to prove ownership of staked assets and either redeem that underlying asset or receive fees and other forms of compensation generated by the assets you staked. Not so different from the bank notes a 15th century Venetian merchant might receive when he deposited some gold with Medici bank.
It seems that this term has grown in use to cover just about any token given to a staker of assets in deFi, even when the purpose of that stake goes beyond simple liquidity provision. Something to keep in mind on your own journey to understanding the space.
collections of staked assets : “liquidity pools”
Liquidity pools are used in multiple contexts within deFI but at this point all you need to know is that a liquidity pool is a collection of staked assets (and not necessarily a collection of only a single asset) that has been staked to a single “location” (generally, a single smart contract or several linked smart contracts) and which is available for “use” - market making, lending etc. More on this later.
distributing governance tokens via staking
staking and governance on Yearn
As lending platforms began to multiply, lenders looked to optimize their returns by finding the platform with the highest yield (more on this later). Andre Cronje built the Yearn protocol to automate this process. A user could stake a given coin (let’s say Dai) into Yearn’s Dai liquidity pool. The Yearn protocol would figure out the highest yielding platform for that Dai and invest it there. In the meantime, the original user would be issued a token to represent that stake (“liquidity provider token”), in this case yDai tokens that represented her stake in Yearn’s pool of staked Dai. This token could be used later to collect the subsequent fees earned by the underlying Dai investment that the Yearn protocol made on the user’s behalf. It could also be used to redeem the underlying Dai when the user wanted her Dai back.
As the protocol to execute these types of activities expanded (different strategies, different assets etc.), Andres wanted to democratize the decision making that went into the expansion of it. So, he minted a new token - YFI - that would grant its holders rights to submit and vote on proposals for changes to the Yearn protocol. Andres did two interesting things in connection with the distribution of YFI.
First, no tokens at all were “pre-mined” or in any way “reserved” for the original builders or investors of Yearn. At this point, it had been a fairly typical practice across crypto to reserve a “free” bucket of tokens or coins for the founders before the rest of the tokens were made available to a wider constituency. There are still many protocols today which, in their technical architecture, are decentralized but where decision making rights and ultimate power are still vested in the hands of a few because of the way these pre-mined tokens were distributed. This is not too dissimilar from the way equity is distributed among the initial shareholders of a corporate entity in default world. Andres' departure from this practice was lauded for it’s “fairness” and commitment to creating a more fully decentralized protocol.
Second he linked the distribution of these tokens to staking. If someone wanted some YFI, the only way to get it was to first stake some other coin into the Yearn protocol (e.g. the Dai from our previous example). The user would then would have to do a second stake - this time of his yDai - into another smart contract which was responsible for the distribution of the YFI governance token. For every day the user left his yDai staked in the YFI distribution contract, he would receive YFI. In this way, Andres incentivized users to provide liquidity to the Yearn protocol and introduced a new use for staking - as a tool for [more] equitable distribution of protocol governance rights. A link to his original post 2 about this is listed in the resources section; a fun time capsule and a quick read.
staking and governance on Compound
Compound was also an early user of this concept - governance tokens for staking. Though in Compound’s case, the motivations were slightly different. Yearn, as described, started as a protocol that would, on a users behalf, choose the highest yielding investment options for a “staker” of crypto assets. So, it wasn’t directly lending to “end-users” (or maybe end-borrowers is a better term here). Whereas, Compound was actually doing the lending to the end-borrower. While the uses of the staked assets on each of the protocols were different, the basic need to distribute governance rights was more or less the same.
Also, Yearn was further along in it’s growth when it distributed its governance tokens. It was really just looking for a fair[er] method to distribute governance tokens that would avoid concentrating decision-making power in too few hands. Compound on the other hand, was looking to incentivize folks to use their platform altogether, in addition to needing a way to more fairly distribute governance tokens. In any case, Compound also successfully employed the governance-tokens-for-liquidity arrangement.
staking to provide liquidity and getting rewarded for it : “liquidity mining”
When I’ve seen references to “liquidity mining”, it seems to refer to the Yearn and Compound stories as the start of this activity. I think liquidity mining is quite a vague term but for reference and the sake of disambiguation I’m making a note on it. Liquidity mining, as far as I can tell, is just staking. Perhaps you could say liquidity mining refers to staking for the sake of providing liquidity. So, someone who stakes on a lending platform like Compound is “liquidity mining”. Someone who stakes on “yield generation” platform like Yearn is “liquidity mining”. And someone who stakes into a liquidity pool that is used by a dex to facilitate trades (see next section) is “liquidity mining”.
pools of staked assets used to make markets: “automated market makers”
Staking, and it’s offspring - liquidity pools - have also changed the game for exchanges, a central pillar of decentralized finance. In the early days of staking in deFi, the staking that occurred was in the service of lending a single asset and posting collateral for that asset. Stake ETH and then ETH was loaned out. BTC might be staked as collateral. And then Uniswap came along…
Recall the “ideals” of decentralized finance - open, transparent, non-custodial, decentralized. Before liquidity pools came on to the scene, if you wanted to create a decentralized exchange, you would need to become, effectively, an Uber of trading. You would need to match a seller with a buyer for every trade. Or, in trading parlance, you’d need an order book. If you wanted to be truly decentralized, you would need to build this order book on the blockchain itself rather than on a centralized off-chain server (this is what centralized exchanges like Gemini do). Given how computationally intensive (and therefore financially expensive) this functionality is, building an order-book on a blockchain was commercially impractical.
Historically this is where market makers would come in. Stock brokers, banks etc., being heavily capitalized, would take up the buying side of a seller who couldn’t find a “real” buyer. They would do so based on the bet that they could eventually turn around and sell those assets later when a buyer came along. They might lose some money some of the time or have to hold onto the asset for a while before they could sell it but in the long run the bet was that providing this liquidity to the market would net an overall profit; especially based on the fees they’d charge to participate in the transaction. Early on, exchanges used crypto hedge funds as brokers (I think this practice is still employed quite a bit but haven’t confirmed it). While the use of a broker would disqualify an exchange as “truly” decentralized (at least as we defined it above), it got the job done. And it helped provide critical liquidity for the still young deFi space.
And now back to Uniswap. Uniswap introduced automated market makers as a way to provide liquidity without the need for an on-chain order book or brokers. It changed the game for exchanges in the process.
At the heart of an automated market maker was a twist on the already familiar liquidity pool. Rather than pooling a single asset, AMM’s used pools comprised of two (or sometimes more) assets - trading pairs. When someone wanted to sell a coin, rather than needing to find a specific buyer for that coin, he could simply deposit that coin into the pool and withdraw the other half of the pair. Algorithms would determine the exchange rate and transaction fee paid based on how much of each coin is available in the pool (and probably other factors). The algorithms were designed so that the pool would never actually run out of either asset. Rather, what would happen is that the transaction fee would become prohibitively high as supply dwindled. This would, both incentivize further liquidity to be provided (increased returns to stakers) and discourage trades (higher fees and less favorable exchange rates) until the pool was replenished.
A secondary benefit of the use of AMMs is that they made it possible for anyone to be a market maker. Ways to earn that were once the province of blue-blood, white-soled old money institutions were suddenly open to the general [crypto-] public.
It’s worth noting that the term AMM and dex are sometimes used interchangeably. In many cases today, dex’s are, at their core, automated market markers. But this is not always the case 3
It’s also worth noting that new chains like Solana, Cardano and ETH’s imminent shift to proof of stake consensus could make functionality like on-chain order books feasible and perhaps reduce the use of AMMs . But for now, AMM’s seem to be the dominant method of implementing dex’s.
optimizing returns across all possible staking opportunities : “yield farming”
As the sea of staking opportunities grew in deFi, it became worthwhile to take a more strategic approach to staking. In the simplest sense, it was basically just a matter of price arbitrage - seeing where the best yield was and getting your assets into that pool (perhaps making some trades along the way to acquire the proper asset). Other tricks were used as well - “simple” leverage as well as more complex strategies involving “chains” of re-hypothecation (treating loaned assets like collateral for a 2nd, 3rd, nth loan…). With the introduction of these more complex strategies, liquidation risk became more serious and systemic consideration for platform builders and investors. Over-collateralization was used to reduce the chances that the notoriously volatile deFi markets could trigger systemically dangerous chain reactions of automatic liquidations.
The surface area of these optimization strategies is significant, complex and rapidly changing so I’m not going to try to bolt that on to this post. I only mention of all of this so that you can get a sense of what the almighty “yield farming” term means. As far as I can tell, this is fundamentally what yield farming is: the activities associated with optimizing returns across all possible staking opportunities.
Here’s a more concise, if crude, way to think about it: “yield farming” is basically any of the things that you read about that are done in connection with staking, that go beyond simply finding a pool, staking your assets, and letting them sit until the lock-up period runs out.
One thing that I found interesting is the mechanics of how one switches between pools while his assets are locked up. Consider this scenario: If you’ve staked somewhere, you might have to commit those funds for a few years. So what happens if you find a more appealing yield opportunity and you want to take advantage of that opportunity, in spite of the fact that your assets are locked up? Well, this is where those liquidity provider tokens come into play. You can’t actually move your assets out of that pool. But you can trade your “deposit slips” for other deposit slips and thereby change which pool you are collecting rewards from and which asset you can ultimately redeem when the lock up period runs out.
To me, this feels a lot like bond trading. You have bonds which represent promises of future income streams of all sorts. You have a view on what the effective yield of a bond will be and you make trades based off of that view to optimize your portfolio.
where to from here
Textbooks could be written about these subjects and even I, as a beginner, could write multiple other posts about them but given that this is a first pass, I’ll leave it at this. In the meantime, I hope this makes deFi a bit less murky.
sources
- Origins and philosophy of deFi via Defiant
- Andres Cronje’s original post about YFI distribution
- Description of different exchange designs
helpful reference material