Compound currently functions in nine markets: BAT, DAI, ETH, REP, SAI, USDC, USDT, WBTC, ZRX. These are the digital assets that you can earn interest on.
Let’s use DAI as an example. Once you supply DAI to the protocol, that value is locked in until you decide to withdraw it. While it’s there, though, you’re agreeing that the protocol can lend that value out, thus earning the whole pot interest. Think of it as a savings account.
Once it’s in there, you can check how much DAI there is at any time, what the current interest rate is, borrow other assets, etc.
Let’s get technical
What does this supply process look like from a technical standpoint?
The protocol uses ERC20-compliant contracts for each of the supported markets. They are called cTokens. They each have an external function: mint
, where the supplied value is sent. This function receives the supplied value, calculates the equivalent number of cTokens depending on the exchange rate, and exchanges them for the supplied value.
For example, if the exchange rate is 1:1, then supplying one ETH will result in the sender receiving one cETH.
The opposite of mint
is a function called redeem
. When a user wants to withdraw their locked-up value, calling redeem
with the desired number of cETH tokens will return the equivalent value of ETH depending on the current exchange rate.
Note: There is also a redeemUnderlying
function that uses the underlying asset units instead of the cToken units as input.