Conventionally, staking is the act of locking-up something valuable that you own in exchange for valuable rights: the right to earn interest on your stake, the right to share in business revenues, a seat at the poker table and so on.
While staking in DeFi has features that are similar to conventional finance, the underlying way in which this takes place is vastly different. This article attempts to create an accessible 101-type explanation into some of the inner workings of popular DeFi protocols.
Ocean Protocol builds on the primitives provided by DeFi to unlock the ability to lend and stake on data assets. Let's dive-in and examine how it comes together.
- "Conventional" DeFi
a.The problem solved by "conventional" DeFi
b.DeFi primitives - Automated Market Makers and Liquidity Pools - Data DeFi on Ocean Market
a.Staking on Data Assets - Adding Liquidity to $OCEAN - Datatoken pools
- Remove Liquidity from $OCEAN - Datatoken pools
- Exercises
- References
"Conventional" DeFi
The problem solved by "conventional" DeFi]
Using the term "conventional" to refer to DeFi seems misplaced because the entire field has been birthed and grown rapidly, relatively recently - roughly in 4 years! I'm still going to use it to contrast features of mainstream DeFi platforms with Data DeFi on Ocean Protocol.
If you've used an online brokerage such as Robinhood to buy stocks or Coinbase to buy crypto, you are probably familiar with the Centralized Order Book (COB) model. Here, we have holders of token A (USD, for instance) making a "Bid" for token B at a specific price. Sellers of token B (BTC, for instance) "Ask" for a certain price of token A at which they'll sell. When Buyers and Sellers converge on a price, a sale happens and tokens exchange hands.
Buyers like buying at lower prices, so we have a larger number of Buyers at lower prices. Sellers like selling at higher prices, so we have a higher number of Sellers at higher prices. The number of buyers and sellers i.e. tokens A and B available to trade at a given price is referred to as liquidity. As you can see below, the liquidity "dries up" between the bid and ask price if Buyers and
Sellers aren't able to agree on a transaction price.
Enter Market Makers [1]. Market Makers are institutional entities that make the process more efficient by buying and selling in between the Bid and Ask prices (Bid-Ask spread) in order to provide liquidity and capture some of the profits that result when the spreads are tiny and the volumes are large.
The reason we call this a Centralized Order Book is because the entire procedure described above takes place on the database of a centralized/private entity, such as Coinbase, RobinHood and so on. Buyers and Sellers enter prices at which they are willing to buy and sell. These orders find their way into a proprietary Database, that matches Buyers to Sellers.
Orchestrating this dance of Buyers and Sellers is now an efficient, heavily regulated mainstream industry with billions in revenue. If we wanted to replicate this process on the blockchain, what difficulties might we run into?
For one, each time an order to buy/sell or modify/cancel is placed, we'd have to modify our smart contract on chain to account for this. This would cost a lot since blockchain writes are expensive. This is also time consuming, because blockchains are comparatively inefficient compared to centralized databases. By the time the smart contract is modified, the price of Token B priced in Token A may have changed significantly on a Centralized Exchange (CEx), resulting in losses for participants.
Automated Market Makers (AMMs henceforth) and Liquidity Pools (Pools henceforth) were created as a solution to this problem. AMMs and Pools are building blocks of DeFi, so it is worth paying closer attention to how they differ from the conventional COB model.
DeFi primitives - AMMs and Liquidity Pools
In a Decentralized Exchange such as Uniswap, a smart contract called a Liquidity Pool (Pool) is first created. DeFi participants, called Liquidity Providers (LP)
"Stake" tokens A and B into this contract. Buyers and Sellers of tokens A and B don't enter Bid and Ask prices. Instead, they simply "swap" the tokens that they hold with the Pool in exchange for the other token in the Pool pair.
LPs are incentivized to supply liquidity by giving them incentives. These include, but are not limited to a share of the fees generated when transactions take place, special types of tokens called LP tokens which can be quite valuable in open marketplaces and/or governance rights to the protocol.
In exchange for incentives, LPs "Lock-Up" their stake so that A and B are always available for interested parties. This seems to solve the problem of making liquidity available, but what about the price of tokens? In COBs, participants can enter prices below/above which they will not sell. This allows control over their buying and selling price. In the absence of of a COB, how does price get decided?
Enter Automated Market Makers [2]. Automated Market Makers aim to solve the problem of price discovery by controlling the total number of tokens of A and B in the pool and letting the ratio of the tokens in the pool determine the relative price of the tokens.
In the example below, we have two tokens, A and B, that have an initial supply of 1000 and 100 respectively, for instance.
Let's say a Buyer possessing a 100 B tokens wishes to receive A tokens in exchange. B is deposited into the pool, making the number of B tokens = 200. What is the number of A tokens that the buyer receives? Remembering that the AMM keeps the product of the number of A and B tokens constant at all times, we get the following
The Buyer has received 500 A tokens in exchange for 100 B tokens, giving an implied price of 5 A tokens per B token. The demand and supply of A and B relative to each other and the impact on price is summarized in the following graph modified from [2] below.
As the relative number of B tokens in the pool goes up, the number of A tokens returned in exchange reduces. In other words, each marginal B is worth lesser and lesser in terms of A. The converse is also true. If the number of B tokens reduces because of demand, the AMM constant liquidity provision ensures that each marginal B rises in terms of A. In the example above, for instance, if we had deposited 1000 A instead, we now have 2000 As and 100000/2000 = 50 B tokens, meaning that 50 Bs would be returned to the buyer in exchange for 1000 A. The implied price of As per unit B is now 1000/50 = 20. The relative number of A/B tokens in the pool ends up determining the price of the token priced in terms of the other dynamically.
The paragraphs above are a simple summary of how AMMs and Pools work. There are a few things that I glossed over in the explanation above. Each A/B or B/A swap transaction is accompanied by a fee that is paid by the user. The fee is distributed to the LPs in various forms proportional to their stake. Another feature in the system above is that LPs supply both tokens to create the liquidity pool or maintain it. This is NOT the type of liquidity provisioning that happens on Ocean Market, where liquidity is provided by staking $OCEAN versus a Datatoken.
Conveniently, this is the next topic I'll cover.
Adding Liquidity to $OCEAN - Datatoken pools
Ocean Market takes the DeFi concepts outlined above and tweaks them slightly to make them useful for data assets. The figure below summarizes the key differences between Ocean Market and other Liquidity Pools.
Let's quickly go through some key differences.
- Staking is the act of adding $OCEAN to a $OCEAN-Datatoken pool. Ocean Market uses Balancer under the hood to provide the capability of unidirectional (using one token) liquidity provisioning. Contrast this to bidirectional pools described above.
- Ocean Market fixes the ratio of $OCEAN/Datatokens initially (as of Ocean Protocol V3, as of this writing) to 70/30. Contrast this to pools such as Uniswap for instance where LPs typically provide a 50/50 ratio.
- Ocean Market allows initial price setting on Datatokens in a pool. Contrast this to the scenario described above, the price is implied by the ratio of the number of tokens.
- The greater the amount of $OCEAN staked on a Data Asset, the greater the implied utility / confidence in the Data Asset. Thus Staking on a Data Asset is akin to Data Asset curation. A greater number of curators/independent liquidity providers should be taken to be a proxy for Data Asset quality.
If you are interested in becoming a LP on Ocean Market, you might want to dig deeper into these points by reading the Ocean Protocol Whitepaper [4].
For now, let's go through the steps involved in Staking on Data Assets in Ocean Market using the FABSTA-66 token created in the previous section on Publishing.
Clicking on the "Pool" option in the Datatoken page on Ocean Market gives you a quick summary of essential statistics pertaining to the Pool.
Besides checking the Datatoken details on the Pool Stats tab, you should also dig into the details of the Pool on Etherscan. The pool was created with an initial supply of 21 $OCEAN to 9 FABSTA-66s. Remember that users swap liqudity into and out of this pool. As of this writing, a total of 42 $OCEAN were deposited into the pool, with an implied price of ~2.5 $OCEANS per FABSTA-66.
To provide liquidity to this pool, first confirm that you have $OCEAN in your wallet, click on "ADD-LIQUDITY" and read the disclaimers provided.
Next, enter the number of $OCEAN you are willing to stake. Ocean Market may choose to limit the maximum amount allowed to be staked at a time. In exchange for providing liquidity, you will earn a 0.1% stake of every transaction in the pool proportional to your share in the pool. Your share in the pool will also be displayed in terms of percentages, $OCEAN value and FABSTA-66 values.
If you choose to approve the transaction, Metamask will take your permission to first take $OCEAN from your wallet and add it to the pool. This will be two separate transactions and the UI on Ocean Market will change to reflect this additional step. It is unclear if Ocean Protocol takes a transaction fee on Liquidity Provisioning at this time.
Upon completion of your transaction and confirmation of the transaction being written to testnet, pool statistics should now reflect number of pool shares you own, the total number of pool shares, the total $OCEAN in the pool and so on. Confirm that this is indeed the case.
Having staked on a Data Asset, you are now a bonafide Data DeFi market participant. Congratulations! Ocean Market will deposit your wallet with transaction fees denominated in $OCEAN.
Remove Liquidity from $OCEAN - Datatoken pools
Removing liquidity is the act of exchanging your locked-up stake in exchange for $OCEAN. Since Staking and liquidity provisioning is a proxy for Data Asset curation, one might guess that withdrawal of liquidity is a proxy for loss of confidence in a Data Asset. An LP might want to do this for several reasons, outlined below:
- The Data Asset quality has materially deteriorated over time or is now irrelevant.
- 1 above has resulted in other LPs withdrawing their stake.
- An LP might need $OCEAN to deploy to other Data Assets.
Whatever the reason, the act of removing liqudity results in a reduction of $OCEAN per Datatoken available in a pool and is undesirable for the holders of these Datatokens.
Let's take a look at how liquidity is removed from a $OCEAN - Datatoken pool using FABSTA-66. Clicking on "Remove Liquidity" in the "POOL" tab should modify the tab contents as shown below.
You have the option to remove a portion of your stake or the maximum allowed which is kept as 40% to discourage sudden liqudity draining from the pool. As always, Metamask will ask for your permission to make the required transfers and Ocean will subsequently display a success message if you did this correctly. Your wallet should reflect this balance when the transaction is confirmed on Etherscan.
If you've followed along so far, you should be fairly familiar with the basic mechanics of creating a Metamask Wallet, interacting with Ocean Market, finding Data Assets to Buy, Trade and Stake and Publishing your Assets on Ocean Market. That's a lot of ground covered!
In the next and final chapter of this guide, we'll take a look at how Data Assets can be created and sold on alternate blockchains, such as the Energy Web Chain, Binance, Moonriver and Polygon.
Click here to go back to the table of contents of the Data DeFi guide.
Exercises
- Stake some Rinkeby $OCEAN on to the FABSTA-66 Datatoken. What is the maximum amount available to stake when you do it the first time?
- Try and remove liquidity from the FABSTA-66 Datatoken using the procedure outlined above.
- Observe the price of the FABSTA-66 Datatoken when you do exercises 1 and 2 above. Since the pool is relatively small, minor withdrawals can have a very big imapct on the price. While this is especially painful on the downside, it can be very lucrative on the upside and more and more liquidity comes into the pool. Think about this concept as you choose assets to stake-on.
References
- Market Maker https://www.investopedia.com/terms/m/marketmaker.asp
- AMM 101- https://easydefi.substack.com/p/automated-market-makers-101
- Balancer - https://balancer.gitbook.io/balancer/core-concepts/protocol/background-1
- Ocean Protocol Whitepaper - https://oceanprotocol.com/tech-whitepaper.pdf
- FABSTA-66 - https://market.oceanprotocol.com/asset/did:op:fC6E0e75CFe3c6323ecd37BF69Aa9180a4bC127D