Have you ever wondered about Compound Finance and how their tokens (i.e., cETH, cDAI, and cUSDC) work? Well, Compound is an algorithmic interest rate protocol that runs on Ethereum. With Compound, developers can unlock new worlds of decentralized financial applications, and regular users, who prefer to hold their digital assets, can earn interest by doing so.
After all, keeping assets in a crypto wallet doesn't get a user anything except the peace of mind that the assets are in a safe place while they hopefully increase in value over time. However, with Compound, users can instantly start earning a variable interest rate by supplying a digital asset to the Compound protocol with interest accruing on each Ethereum block.
Currently, nwq blocks are mined every 13 seconds, and the good news is there is no minimum or maximum amount of time users have to tie up their funds. They can withdraw their principal plus any interest earned anytime they feel like it.
This article will briefly overview how Compound works before delving into some of the Compound tokens (cTokens) - specifically cETH, cDai, and cUSDC.
If you want to get proficient with Compound or any other blockchain protocols, sign up for Ivan on Tech Academy and start your educational journey today. The Crypto for Beginners course is a good one, if you're new. If you're already familiar with the basics, check out Ethereum 101.
Supplying Assets to Compound
Before we dig into the specific cTokens, let's look a little more closely at Compound. With the Compound platform, developers can build innovative DeFi products, and regular users can contribute assets to a large liquidity pool for others to borrow from and then share in the interest payments.
How it works is, users go to the Compound Markets page and pick which asset they want to borrow from the list of supported assets. The mint function transfers crypto assets into Compound, and the funds start accumulating interest.
Assets supplied to the protocol can be used as collateral after the user "enters the market" for that asset. Also, a user can simultaneously enter multiple markets. Assets supplied as collateral earn interest so long as they are in the Compound protocol. Users cannot redeem their tokens, however, while they are in the collateral state.
To interact with smart contracts on Compound, developers can create dApps while non-technical users can use a wallet interface like Argent or Coinbase. At the time of this writing, Compound only supports ERC-20 tokens for such purposes.
You can find the supported assets list and varying exchange rates at Compound Finance Markets.
Borrowing From Compound - the Collateral Factor
Users can borrow funds via a user interface. But before we step through the borrowing sequence, let's look at some key points:
1. How to borrow crypto.
Users must put up a different type of crypto as collateral than what they are borrowing. They will, however, use the same mint function that users do for supplying assets.
2. The maximum borrowing amount.
The assets that users supply determine the max borrowing amount. For example, let's say the collateral factor for Dai is 75%. If a user supplies 1000 Dai, the most they can borrow is 750 Dai worth of assets.
3. Different collateral factors.
Take note that different assets on Compound might possess various collateral factors. The Comptroller contract can fetch the collateral factors, and Compound governance has the power to change these factors.
It stands to reason that if a user has various assets with different collateral factors, trying to calculate an account's liquidity or the maximum borrow amount can be challenging to figure out.
cTokens are a necessary component to interact with the Compound protocol. Essentially, whenever a user decides to borrow, repay, liquidate, mint or transfer, they will do so with the cToken contract.
Also, users get cTokens from Compound in exchange for supplying assets. These cTokens are ERC-20 standard, and users can redeem them at any time for their underlying tokens. As interest accrues over time, users can redeem cTokens at an exchange rate relative to the supplied assets.
Types of cTokens
There are currently two types of cTokens:
2. Other cERC-20 assets such as cDai and cUSDC
Assets supported by Compound offers users the chance to:
1. Earn interest based on the exchange rate.
2. Use cTokens as collateral.
Compound's Mint Function
The amount of interest a user can earn depends on the asset's current supply rate. The user receives cTokens based on the number of underlying assets they supply, divided by the current exchange rate.
So, users can supply one or multiple supported tokens to Compound as collateral. When a user calls the mint function, the cToken smart contract returns cTokens in exchange for the deposited asset.
How to View cTokens
To check prices on listed cTokens, users can go to Etherscan or type in their address to find their cTokens. Coinbase wallet and MetaMask also offer cToken balance integration.
This term stands for the account supplying the underlying assets that will take possession of the minted cTokens.
The mintAmount refers to the amount of the asset supplied. Remember, users must approve the cToken first before providing tokens.
3. Redeem function:
For users to access their underlying supply of assets, the redeem function will convert the cTokens (i.e., cUSDC) into the underlying asset (USDC) and return them to the user.
The tokens received upon redeeming will equal the number of cTokens multiplied by the Exchange Rate but is dependent on the market's available liquidity.
The Difference between cETH, cDai, and cUSDC
There are different ways to supply assets to Compound depending on whether it's ETH or other ERC-20 tokens. ETH has its supply method to get cETH. But the way users get cETH is different from getting other cTokens such as cDai or cUSDC.
To supply ETH to the protocol requires calling the mint function. Developers can "call" the mint function via a public network like Ropsten or Kovan so long as they have:
1. ETH available in their wallet.
2. The wallet's private key stored as an "environment variable," and the
3. Infura API key ready.
Regular users don't need to go through all that rigamarole. They can call the mint function with their crypto wallet. The mint function will send ETH to the Compound smart contract address and then mint cETH tokens to transfer back to the supplier's wallet.
To mint other cTokens like cDai or cUSDC, the user's wallet (or other application) must first call the approve function that's tethered to the underlying token's contract. All ERC-20 tokens will have an accompanying approve function.
Dai and USDC are stablecoins. If you want to learn about the Top 5 Stablecoins, please read our article. If you want to get a first-class blockchain education, make sure to check out Ivan on Tech Academy.
In the past, with Compound v1, the protocol added any earned interest to a user's account balance. That's because Compound used to have only one smart contract for multiple assets. However, with the v2 upgrade, individual tokens have their unique "asset gateways."
Compound's upgrade to v2 included adding cTokens such as cETH, cDai, cUSDC, and others to the mix. So, now when a user supplies Dai or USDC, they will receive cDai or cUSDC, respectively.
With v2 came the ability for users to supply tokens and receive specific cTokens representing the underlying asset, all while earning a variable interest rate. In summary, cTokens represent each user's lending balance and the interest accrued.
What Is cETH?
cETH acts as proof of ownership for users who supply ETH to the Compound lending pool. It comes with its own exchange rates. What happens is, cETH wraps ETH while other cERC-20 tokens wrap their underlying asset.
What Is cDai?
Likewise, cDAI acts as proof of ownership for users who supply DAI to Compound. For crypto users who like to HODL their tokens, exchanging Dai for cDai is like starting a traditional savings account (when savings accounts used to pay a decent interest rate). After all, in the DeFi space, lending is one of the more popular ways to earn passive income.
What Is cUSDC?
As you can probably tell by now, cUSDC is Compound's ERC-20 token that provides proof of ownership for the USDC tokens supplied to Compound. If a user deposits USDC, they receive cUSDC tokens. Think of cUSDC as a receipt for depositing USDC.
cUSDC holders earn the prevailing market interest rate. Hence, interest payments depend on the cTokens exchange rate. Over time, each cUSDC becomes worth more of its underlying asset—USDC, while the amount of cUSDC in the user's wallet remains the same.
So, a user deposits USDC to Compound. The protocol's mint function mints cUSDC tokens to the user's application or wallet. Afterward, users can redeem their underlying USDC whenever they want as long as Compound has enough liquidity to redeem them.
Furthermore, while the way to supply ETH for cETH, Dai for cDAI, and USDC for cUSDC is similar, they will exhibit a different UX experience with other interfaces depending on the asset the user supplies.
Also, each market has its individual APR, but interest rates reside within the cToken asset and not with its owner.
How to Earn Interest with cETH, cDAI, and cUSDC
Users can earn interest simply by holding cTokens. That's because as time passes, the cTokens become worth an increasing amount of the underlying asset. So, the cTokens become worth more while their number remains the same.
In other words, the number of cTokens doesn't increase, but they do accumulate interest through Compound's exchange rate.
cToken Exchange Rate
Each user receives the same cToken exchange rate based on the specific asset. To better understand it, let's look at ETH and cETH.
One cETH is worth 0.02 ETH. But after a year, thanks to a compounding interest rate, one cETH could be worth 0.021591 ETH.
Or, let's say a user supplies 100 Dai with an exchange rate of 0.02 and receives 5000 cDAI (100/0.2). Later, they decide to withdraw their Dai after the exchange rate reaches 0.0216; the user can redeem the entire 5000 cDai and get 108 Dai in return (5,000 * 0.0216). This scenario would result in an $8 profit (108 - 100).
Or the user could withdraw their original 100 Dai and keep the rest in cDai to continue earning interest. Okay, so not very exciting returns with smaller increments, but you can see how cDai grows in value with interest accruing in proportion to the interest rate.
Trading and Transferring cETH, cDai, and cUSDC
The great thing about Compound's decision to distribute cTokens as ERC20 tokens is that they've freed up assets that can either be locked up or used elsewhere. This feature opens up a new world of liquidity opportunities for cToken holders to put them to work on other protocols.
cETH, cDai, cUSDC, and other cERC-20 tokens can be traded or transferred and don't necessarily have to go directly into cold storage. Since they are like any other ERC-20 token, cTokens can earn additional interest than Compound offers standalone on the underlying assets. These kinds of liquidity provider opportunities exemplify the lego building blocks that define the DeFi ecosystem at large.
Take Uniswap, for example. Their Dai to cDai liquidity pool exemplifies this kind of interoperability in action. By pooling cDai, users can gain exposure to earn Uniswap trading fees.
Suffice it to say; users can hold cTokens as a tokenized deposit positions, transfer them to other users the same way they would any other digital asset. Or they can go to collateralizing other liquidity pools, or users can exchange them for other digital assets. The entire concept is wildly innovative compared to what customers can find in traditional consumer finance.
Isn't it time for you to join the exciting world of crypto? Blockchain developers are in demand, and the need for skilled coders is only going to increase. Enroll at Ivan on Tech Academy and get a jump on the competition. If you already know how to code, check out the Ethereum Smart Contract Programming 101 course.