By design, DeFi protocols are open-source and permissionless, serving as reliable financial infrastructure upon which developers can build their own applications and platforms quickly and at low cost. Just like Lego blocks, these protocols can be selected and assembled in any combination that developers can dream of, allowing for larger and more complex financial structures to be built out of smaller and simpler elements.
The Interest Rate Lego
Early in DeFi’s history, Compound Labs designed and launched the Compound DeFi protocol as a way for users to earn interest on their digital assets without relying on a trusted third party. The protocol allows anyone with an Ethereum wallet to supply assets and use them as collateral to borrow other assets at interest rates established algorithmically by market forces of supply and demand. If there is more demand to borrow a particular asset, interest rates rise, incentivizing more supply. If there is less demand, interest rates go down, which incentivizes more borrowing.
Supplying digital assets to the Compound crypto protocol feels somewhat like putting your money in a savings account, but there’s no third party with custody of your money; instead, it’s held in a decentralized, blockchain-based protocol and remains in your exclusive control at all times. When you supply assets to the protocol, it will automatically send you cTokens representing those assets in return. Each asset has its own unique cToken; for example, if you supply ETH, you receive cETH, and if you supply USDC, you receive cUSDC. You can use your cTokens to withdraw your assets from the protocol whenever you want.
Your cTokens earn interest over time based on the crypto rates paid by borrowers in the protocol. As interest accrues, the exchange rate between your cTokens and the underlying assets will increase, so that the same number of cTokens you initially received are worth more than the amount of assets you initially supplied. As a result, the interest you earn is always denominated in the same asset that you supplied; if you supplied ETH then you earn interest in ETH, and if you supplied DAI then you earn interest in DAI.
An example: if you supply DAI to the Compound protocol, your DAI will be pooled with all of the DAI supplied by other users, and the protocol will send you cDAI in return. Any users who decide to borrow DAI from the protocol will have to pay interest at the prevailing algorithmic rate, and that interest will accrue to you in the form of an increase in the exchange rate between cDAI and DAI. When you decide to withdraw your DAI, you get back the original amount you supplied plus extra DAI earned as interest.
If you want to borrow assets from the protocol, you first have to supply assets as collateral. You will then be able to borrow other assets up to a certain limit, which is always less in dollar value than the amount of collateral that you supplied. If market conditions change so that the amount you borrowed is more than your limit, like if the value of your supplied assets falls, or the value of your borrowed assets rises, then your position can be “liquidated.” Liquidation happens when a third party repays a portion of your borrowed assets and takes some of your collateral as a reward. Together, overcollateralization and liquidation make sure that the protocol stays solvent.
cTokens as Legos
Since cTokens are built on the ERC-20 standard, they can be used nearly anywhere on Ethereum. These tokens represent a reliable piece of code — audited, reviewed, and backed by real assets — that can be plugged into both new and existing protocols and applications. This means developers who want to utilize a decentralized crypto interest rate market don’t have to build their own from scratch; instead, they can utilize the Compound protocol by incorporating cTokens into their own project
One of the best examples of using cTokens as a Lego is the Curve protocol. Curve is an “automated market maker” protocol that allows users to exchange digital assets without having to use a custodial trading platform. Like the Compound protocol, Curve works by maintaining pools of digital assets that are available for users to buy and sell. To make good use of those assets while they sit idle, Curve supplies them to the Compound protocol, as well as other DeFi protocols, to generate yield for their owners. Curve is a prime example of DeFi composability.
Building Safe Structures
If DeFi protocols are Lego blocks for developers to use in building new financial structures, then it’s important to remember that all structures are only as strong as their weakest points. DeFi composability is a double-edged sword; in addition to all of its advantages, it also poses some risks. Since the beginning of DeFi, poorly-designed protocols have resulted in millions of dollars in lost funds due to sloppy code and careless decision-making.
This means developers who build and use DeFi protocols must pay extra attention to safety. Developers should prioritize safeguarding user funds by deeply analyzing protocol security and economic stability; they should also rely more heavily on protocols that are time-worn and battle-tested. One of the major benefits of open-source software is that it tends to be better quality and more secure than proprietary alternatives, but only if it’s exposed to broad scrutiny and vigorous stress-testing. A strong structure can only be built with sturdy materials.
But when handled responsibly, DeFi composability offers the power to produce extraordinary new financial primitives, as we’re seeing now in the Ethereum ecosystem. These tools are valuable not only for DeFi developers to build upon, but also for traditional institutions like exchanges and custodians to implement and offer as products and services to their customers. DeFi may be in its early stages, but it’s growing rapidly and has a bright future ahead.