Engineering at Brex, Apple, Microsoft. I write about fintech, crypto and China
By June 2020, the Compound Protocol was valued at a staggering $ 1 billion, making it the “most valuable” decentralized financial protocol. Last year, DeFi became the hottest topic in crypto. Let’s take a closer look at one of his most popular projects.
This post is a “roundup” on piecing together a synthesis based on core resources such as the whitepaper and developer documentation.
It is common for cryptocurrency holders to buy tokens and leave them idle on accounts. In the past year, the majority of all Ethereum tokens have not moved. Perhaps an “unconscious” tendency borrowed from traditional markets, some cryptocurrency holders abandon assets in the hopes that their value will somehow increase over time.
For fiat currencies, interest rates have served as the “price” of money. It adapts to supply and demand, connecting those who want to borrow with those who can lend. This was not the case with crypto assets. There is still a possibility that tokens will depreciate in value unlike some “real” assets like real estate and dividends on stocks.
Compound is about getting inactive crypto assets up and running. It is an open source Ethereum protocol with interest rate markets that allows users to provision and borrow Ethereum tokens. Through floating rates, Compound creates money markets where anyone can instantly earn interest by providing assets and borrow instantly at a specified interest rate. These interest rates are algorithmically set and tracked through smart contracts with no people in the loop.
While lending / borrowing cryptocurrencies was still possible before Compound, it was less efficient. In particular, there was a lack of liquidity, as stock exchanges had to carry out a “matching” between borrowers and suppliers.
The main features of the dynamic money markets operated by Compound are:
- Liquidity: Users can instantly deposit and withdraw a shared liquidity pool
- Borrowing with collateral: Users can borrow instantly from a money market and use their provided assets as collateral
- Algorithmic interest rates: The protocol sets the interest rates algorithmically based on supply and demand
- Dynamic: No “due dates” for loans
The bid and leverage rates represent the Annual Percentage Yield (APY) of an asset.
If you provide an asset such as DAI, Ethereum, Tether, USD Coin, or Basic Attention Token to the Compound Protocol, you will receive cTokens in exchange. cTokens are simply ERC20 tokens that represent your balance in the compound protocol. The main aspects of cTokens are:
- They represent the asset you provided and earn interest over time
- They can be used as collateral to borrow from the compound protocol
Compound operates in markets, which means that each asset has its own supply and demand market.
Every Ethereum block accrues interest. Every 15 seconds the balance of the cTokens increases by 1 / 2,102,400 of the quoted annual interest rate for the base value.
Let’s go through an example of how you could earn interest by providing DAI:
After providing Compound with DAI, you will receive cTokens to represent the DAI. These cTokens are called cDAI. Each token has an exchange rate for its respective cToken, which means that 1 DAI can be exchanged for a certain amount of cDAI.
The DAI market has an interest rate model. The moment you gain access to cTokens, you start earning interest: over time, each cToken is converted into a growing amount of its underlying asset.
- they deliver 1,000 DAI Mix. At the time of delivery, the exchange rate from DAI to cDAI was 0.02070. Hence, you will earn 1,000 / 0.020070 = 49,825.61 cDAI
- A few months later you would like to redeem your DAI with the cDAI in your wallet. Now that exchange rate has risen to 0.021591. Therefore, 49,825.61 cDAI now corresponds to 49,825.61 * 0.021591 = 1,075.78 DAI
Interest is incurred for all suppliers and borrowers who interact with a market’s cToken contract. When either of the following is triggered, interest is added to the underlying balance of each supplier and borrower:
- Mint (provision of assets Mints cTokens)
- Pay back
Each cToken has a delivery rate and a loan rate that are updated with each Ethereum block. We’ll look at the specifics of asking and lending rates in a moment.
Every market also has excess liquidity: more and more assets are made available than borrowed assets. The interest paid by the borrowers is earned by the suppliers of the asset.
A small part of the interest paid by borrowers is built as reserves (5 – 10% of the market).
As we have already seen, the user receives some cTokens in exchange for provisioning an asset:
Amount of cToken = underlying token delivered / current exchange rate
The exchange rate between cTokens and the base value increases over time. It is calculated by taking into account the total credits and reserves of this asset:
exchangeRate = (underlyingBalance + totalBorrowBalance – reserves) / tokenSupply
The delivery quota, also called APY, that the supplier earns: It results from the following factors:
- Loan installment
- Reserve factor
- Total amount of loans
To borrow at compound, users first provide assets that are used as collateral. For example, you can use DAI as collateral to borrow ETH, ZRX, BAT, and more.
The amount you can borrow depends on the collateral you have provided. The collateral factor is between 0 and 1 and represents the portion of the underlying asset that can be borrowed.
For example, if you delivered $ 100 worth of ETH that has a 75% collateral factor, the maximum you can borrow is $ 75.
The borrowing has no duration and credit can be repaid at any time. However, the interest always piles up. If your credit balance exceeds the limit, your account may be liquidated. This can also happen if the value of the collateral decreases as the value of the assets loaned increases over time.
Liquidation is a reward / incentive mechanism that allows a member of the compound community to repay up to 50% of the asset you owe. In return, you will receive a proportionate amount of your collateral, but at a reduced price.
Practical use cases
Let’s go through some examples of how Compound can be used to trade crypto assets:
It is possible to borrow to increase exposure to a particular asset, or to sell an asset short.
- Alice believes the value of ZRX will increase. She delivers 10,000 ZRX to Compound and uses that as collateral to borrow 30 ETH. Then she sends 30 ETH to an exchange to buy 6,000 more ZRX. Alice now has a commitment of 16,000 ZRX and owes Compound 30 ETH. If the value of ZRX / ETH increases as expected, Alice can buy back the ETH from ZRX and repay Compound for less than the original amount payable (6,000). She would pay off her debt while keeping the excess ZRX.
- Bob wants to short ZRX. So he delivers 100 ETH to Compound and uses it as collateral to borrow 12,000 ZRX. He then sells the 12,000 ZRX for 60 ETH. He now has 160 ETH exposures. If the value of ZRX / ETH goes down, Bob can buy back the 12,000 ZRX for less than 60 ETH. So if he pays off his ZRX 12,000 debt, he can pocket the difference in ETH and keep the excess ETH as profit.
- Suppose you are a “whale,” also known as a large institutional investor, who is betting that BAT will fall in the coming weeks. You borrow BAT tokens from USDC. You instantly sell the assets for USDC on your favorite exchange. A few days later, BAT went down as hoped, so you’re buying back the same amount of BAT, but for less USDC than you originally paid. You return the borrowed BAT and keep the difference between the income from selling BAT for USDC a month ago versus buying back BAT a few days later.
“The individuals, applications and institutions using the Compound Protocol are able to jointly lead it into the future – and have incentives to ensure good governance.” – Robert Leshner, Compound Founder
A guiding philosophy of Compound is that power should be in the hands of the community. For this purpose, the protocol has an on-chain system that distributes COMP (governance) tokens to compound users. The aim is to enable COMP token holders and their representatives to propose and vote on measures that affect the protocol.
Just like cTokens, COMP tokens are ERC-20 assets. Every day, around 2,880 COMP tokens are distributed to users of the protocol across all markets (equivalent to around USD 840,000).
The number 2,880 comes from the fact that 4,229,949 COMP are placed in a Reservoir contract, with roughly 0.44 COMP being distributed per Ethereum block – making a total of roughly 2,880 per day.
50% of the COMP goes to suppliers and the other half to borrowers.
Any address with more than 100,000 COMP can propose governance actions. You can find suggestions here: https://compound.comradery.io/
When a proposal is made, the community is given a 3-day voting period.
COMP was first tested with a limited group of stakeholders. Without relying on the Compound team or other middlemen, the community was able to vote on proposals such as adding a new asset, tether, to the minutes and creating a new DAI interest rate model.
USD locked in compound (note what happened when the COMP token was launched)! Source: https://cipher.substack.com/p/contextualising-compound
June 16 was an important day for Compound as the team announced the official launch of the COMP governance token. This is a milestone in the protocol’s progress towards full decentralization, with the central role of the compound core team gradually being abandoned.
Since you get COMP by simply interacting with the log (even if you are borrowing), it is possible to put large amounts of money in the markets just to get some COMP and then sell it for a profit.
Some big money investors have parked their idle tokens on Compound for a few days in order to receive a sizable amount of COMP because the more you supply, the more COMP you will get. These investors could then sell COMP on exchanges when their prices rise.
On June 25th, Coinbase announced support for Compound (COMP).
We still have to see what else could come out of the COMP rally and what the core team will do next. What we do know is that the explosive development of projects like Compound has proven the unstoppable nature of DeFi.
Join Hacker Noon
Create your free account to unlock your individual reading experience.