Compound Staking

Eniola AgboolaEniola Agboola
5 min read

Compounding is a term commonly used in various career fields. Think of investment opportunities in finance, ROI on real estate properties, or even harvests in agriculture. These examples show that compounding is relevant to us. Some may even classify compound staking as gambling. So, what is compound staking? In this article, you'll learn what compound staking is, how it works, and how you can benefit from it using Compound as a case study.

Compound is a decentralized finance protocol built on the Ethereum network. It allows users to deposit cryptocurrency for a specific period to earn yields or interest through a process called Compound Staking. Unlike the traditional finance system where you can deposit physical assets as collateral, Compound lets you supply crypto assets as collateral to borrow another crypto asset.

Let's do a deep dive into how Compound Finance works. We'd be looking at two major concepts from compound protocol which are:

  1. How to supply assets

  2. How to borrow assets

How to supply assets

For every user who supplies assets into the protocol, they can start earning interest immediately and can withdraw at any time. Interest is calculated and added every Ethereum block, which is about every 13 seconds. Behind the scenes, users are supplying their assets into a liquidity pool where others can borrow from. Those who contribute to the pool earn a portion of the interest paid by the borrowers.

Users who provide assets to Compound receive an ERC20 token called "cTokens" in return. These tokens can be exchanged back for the original assets at any time. As interest accumulates on the supplied assets, the exchange rate of cTokens increases continuously, reflecting the interest earned by the underlying assets.

We can access the Compound protocol through a smart contract or via the following interfaces: Argent, Coinbase Wallet, or app.compound.finance.

How to borrow assets

Compound allows users to borrow assets using other assets as collateral. This flexibility allows them to perform trades or utilize applications with crypto assets they do not currently possess.

For instance, a user who holds ETH can deposit it into Compound and immediately borrow DAI from the protocol.

According to Compound's definition of a borrower

Those that borrow crypto assets from the Compound protocol pay a varying interest rate every Ethereum block. The interest that borrowers pay produces the interest that suppliers earn.

Borrowing assets can be done similiarly to supplying assets into the pool. Users can either use a smart contract or same interfaces as the one for supplying. Let's look at a few steps on how to borrow on compound:

  1. To borrow crypto from the Compound protocol, users must first supply a different type of crypto as collateral. This is done using the same mint function used for supplying assets. Collateral assets earn interest while they are in the protocol, but users cannot redeem or transfer them while they are being used as collateral for an active borrow.

  2. The maximum amount users can borrow is determined by the collateral factors of the assets they have supplied. For example, if an asset has a collateral factor of 75% on Compound, it means that users can borrow up to 75% of the value of that asset that they have supplied as collateral. The remaining 25% serves as a buffer to protect against price fluctuations and potential losses. Each asset on Compound may have a different collateral factor. These factors can be fetched using the Comptroller contract and can be adjusted by Compound Governance, with a minimum waiting period of seven days.

  3. Assets supplied to the protocol cannot be initially used as collateral. To indicate that you want to use an asset as collateral, you need to "enter the market" for that asset. An account can enter multiple markets simultaneously.

  4. If you have multiple collateral assets with different collateral factors, the Comptroller contract provides a function to calculate your account’s liquidity. This liquidity is a USD-denominated value representing the maximum amount you are allowed to borrow. It's important not to borrow this entire amount at once because your account could be liquidated as soon as the protocol accrues interest.

  5. Compound uses its own Price Feed contract, powered by Chainlink, to determine the maximum borrow amount and to assess if a user’s account is insolvent. You can find the Open Price Feed documentation on the Compound website.

  6. This is the sum of a user’s current borrowed amount plus the interest that needs to be repaid. Each cToken contract provides an easy-to-use function to calculate this.

  7. Borrowers owe interest based on the prevailing rate of the asset they are borrowing. The Borrow Rate is added to the account’s Borrow Balance every Ethereum block. Borrowers have the option to repay some or all of their borrow whenever they choose, as long as they are not insolvent.

  8. An account becomes insolvent when its Borrow Balance exceeds the allowed amount according to the collateral factor. When this happens, other users can repay a portion of the outstanding borrow in exchange for a portion of the collateral, with an 8% liquidation incentive (subject to change through Compound’s governance system). Liquidation is detrimental because the borrower loses some of their collateral.

  9. Borrowed assets can be repaid using a function provided by the respective cToken contract. Once a borrow is repaid, the account’s collateral can be fully redeemed or transferred. There are also functions in the cToken contracts to repay a borrow on behalf of another account.

0
Subscribe to my newsletter

Read articles from Eniola Agboola directly inside your inbox. Subscribe to the newsletter, and don't miss out.

Written by

Eniola Agboola
Eniola Agboola

I love writing smart contract. I teach kids how to code. Occasionally, I love to write articles.