DeFi
Understand how DeFi works, how you can participate in it and what to look out for.
What is DeFi?
Decentralized Finance or DeFi is a novel financial system that operates independently and does not rely on centralized institutions like banks, credit unions, or insurance funds. DeFi allows users to access financial services such as borrowing, lending, and trading without the need to trust any centralized entities. Such financial services are typically accessible via applications built on top of decentralized protocols, and are known as dApss (decentralized apps).
What is a Stablecoin?
A stablecoin is a type of cryptocurrency whose value is pegged to an asset. An asset can be another cryptocurrency (or basket of cryptocurrencies), fiat money such as the U.S. Dollar and Euro or even commodities such as gold. Stablecoins aim to reduce volatility compared to other cryptocurrencies such as Bitcoin or Ethereum, and offer buyers and sellers better certainty that the value of the asset they just traded will not rise or crash unexpectedly. Depending on the underlying asset backing the stablecoin, different types of advantages and disadvantages can arise, as shown in the following sections. While in many cases the desired price (i.e. peg) of the stablecoin is the same as the price of its backing asset (i.e. collateral), there are cases in which these can be different.
Fiat Backed Stablecoins
As the name implies, fiat-backed stablecoins (FBS) are tokens that are associated with the value of a particular fiat currency. Usually, these tokens are based on the US dollar and hold their value fixed at a 1:1 ratio. The stability of the fixed value comes from the fact that the company offering the stablecoin has a sizable reserve of the backing fiat currency, and will only mint a number of stablecoins that exactly reflect this reserve amount.
While users need to trust such a third party that is offering stablecoins, FBS are relatively easy to understand and have generally been less volatile compared to their alternatives. Another key concern with FBS in the cryptocurrency ecosystem is that since they are affiliated to fiat currencies, they are by extension affected by the control and policies of the government issuing the fiat currency, i.e. they are prone to the structural problems of centralisation.
Cryptocurrency Backed Stablecoins
Cryptocurrency Backed Stablecoins (CBS) are those which use crypto-assets as their stabilising reserve. The working principle is similar to FBS, with the key difference being that the backing process for FBS takes place off-chain, i.e. in traditional financial and legal systems, while with CBS the backing takes place on-chain, i.e. the backing asset is completely independent of traditional finance and lives on the blockchain (e.g. Ether). This is of great advantage in terms of trust, as the amount and nature of the reserve currency is open to public scrutiny because of the decentralised nature of the platform.
However, problems with CBS have cropped up in the past where they’ve had difficulty in maintaining their peg between the backing asset and the issued stablecoin.
Non-collateralised Stablecoins
Non-collateralised Stablecoins are those which maintain stability in their price without any backing asset, i.e. without the use of any collateral. The tokens rely on an algorithm that is able to change the supply volume of the token if required, to maintain the token’s price. Non-collateralized stablecoins rely on smart contracts to sell tokens if the price falls below the peg (i.e. the desired stable price) or to supply tokens to the market if the value increases. In this way, the token remains stable and holds its peg.
The clearest advantage with Non-collateralised Stablecoins is that since they do not rely on any pool of backing assets, they do not carry any of the problems of centralisation. Instead, investors can scrutinise and place trust in the design of the smart contract. However, the mechanisms used here tend to be quite complex, which means that it is not always clear to everyone if the outcome will be as planned.
What is a Decentralised Exchange?
Centralized exchanges, both in traditional markets and in crypto, operate by means of the order book model. That means that a buyer or seller posts an order, and then this order is executed when someone else fills it with a corresponding buy/sell order. This works well only because centralized exchanges use market makers, i.e. entities that agree to always buy or sell at a certain price (and they make money due to the difference between the buy and sell price). Without market makers, an exchange wouldn’t be liquid enough, because it would take a very long time for an order to be filled.
Decentralized exchanges (DEXs), on the other hand, need to work differently. Implementing an order book model on the blockchain (e.g. Ethereum in its current state) would be impractical, as every transaction costs a gas fee, and an order book exchange relies on the ability to place a large number of orders (many of which don’t end up being filled).
Because DEXs can’t make use of the order book model in a practical way, they rely on liquidity pools to provide a liquid market for a given pair. The way this works is that, in order to create a market for a given pair, the two assets are deposited into a liquidity pool of a DEX protocol at a specific ratio (most commonly with the value of the assets being equal). Then, any user can trade the pair directly from the pool, by swapping one asset for the other.
Unlike the order book model, the price isn’t determined by bid and ask orders, but rather automatically responds to supply and demand via an automated market maker (AMM). The simplest AMM is the constant product model, which is used by Uniswap, and which regulates the price by keeping the mathematical product of the amounts of the two assets constant. Therefore, when there is heavy demand for one asset, its price automatically increases in order to make sure the product remains the same. Furthermore, the price always reflects the prices on other exchanges because of arbitrage: as soon as there is a discrepancy, arbitrageurs (often automated programs) will step in and make a profit on the difference between the two exchanges, driving the price to the prevailing market level.
What is the role of Liquidity Pools?
The trading fees determined by the protocol, rather than being collected by a centralized exchange, are left in the liquidity pool and distributed to the liquidity providers according to the share of liquidity that they provide. This means that providing liquidity can be a decent way to make a passive income in DeFi.
How do lending and borrowing work?
DeFi lending protocols differ from banks in that the whole protocol is entirely on-chain and not controlled by any centralized entity. This means that the difference between the lending and borrowing APY (annual percentage yield) can be significantly smaller than in traditional finance, as the whole process runs much more efficiently.
We should note that there are also centralized lending and borrowing companies in crypto which also offer better returns than traditional banking due to the increased efficiency of dealing with cryptocurrencies rather than fiat. However, this still requires you to trust the companies and to undergo KYC (Know Your Customer) checks, revealing your identity. In DeFi, on the other hand, you only need to trust that the smart contract is well written and doesn’t contain any bugs, and you can borrow or lend crypto without revealing anything except your public wallet address.
Compound and Aave
To explain how lending and borrowing works, we can take the example of Compound and Aave, currently the two most popular protocols. Both work similarly when it comes to borrowing: a user deposits collateral into the protocol (in the form of a particular token) and receives a loan in another token. When the user pays back the loan plus interest, the collateral is returned to them.
Due to the volatility of crypto, DeFi loans are always overcollateralized. This means that, for example, if you want to borrow 1000 USDT with ETH as collateral, you need to deposit 1250 USD worth of ETH. So why would one take out a loan if they have to deposit more in collateral than the loan is worth (rather than just selling the collateral)? The main reasons are that a user needs funds at a particular time in order to deal with some unforeseen event, or that they’re bullish on the collateral token and don’t want to sell it. In some jurisdictions, there are also tax benefits of taking out a loan compared to selling crypto.
When it comes to lending, the basic principle of Compound and Aave is the same, but it is implemented differently. In both cases, the user supplies an asset to the protocol, and that asset is then used for loans. In return for the tokens supplied, the protocol issues new tokens which represent the supplied asset plus interest (and which can be transferred just like any other token). When these tokens are returned, the user receives the underlying asset plus interest for the time that it was supplied.
The main difference between Compound and Aave is the ratio between the supplied tokens and the tokens that the user receives (these are called cTokens in Compound and aTokens in Aave). In Compound, the exchange rate gradually increases over time (e.g., the user receives 500 cETH tokens for 1 ETH, and upon redeeming them a year later, they receive 1.1 ETH for their 500 cETH tokens due to the change in exchange rate). In Aave, aTokens are issued and redeemed at a 1:1 ratio to the supplied tokens, and the protocol rewards interest by continually increasing the user’s aToken balance.
How do interest rates work?
An important difference between DeFi and CeFi (centralised finance) in lending and borrowing is that the interest rates are usually calculated for each block on the chain, according to the supply and demand for each particular asset.
While this is an improvement with respect to the usually slow-changing interest rates of CeFi, which can’t respond to the market demands as quickly, it also means that it’s necessary to constantly keep up to date on the rates if you want the highest yield. It also applies to the borrowing interest, so you need to keep track of the changes so that you know how much interest you will need to pay back. If you want to take a more hands-off approach to borrowing, Aave also offers a stable borrow APR (annual percentage rate), which doesn’t change in the short term.
As far as the practicalities are concerned, using lending and borrowing dApps is similar to using DEXs. All you need is a wallet and you’re good to go: just go to the dApp website, connect your wallet and choose the token that you want to supply or borrow.
How can I start with DeFi?
You can set up a wallet on your own using a reputed service such as MetaMask. In this case, follow the on-screen instructions to create a new address, and securely backup your private key and secret seed phrase. Then, open the exchange Dapp and connect your wallet (this simply enables the DEX to see your public address and doesn’t incur a gas fee). When you find the pair you want to trade, type in the amount and swap, and then you will have to confirm the transaction in your wallet. Be careful with the gas fee, though: if it’s high, you can consider setting it manually after checking the current average gas price on Etherscan or another similar website. Bear in mind that, the lower the fee, the longer it will take for the transaction to be confirmed.
If you’re buying a newly listed coin, one that isn’t on the DEX’s default list, you need to be extremely careful that you have the correct link to the trading pair. Make sure that you get it from the project’s official website or social media pages (and not just a page that looks like the official one) – anyone can create an ERC20 (or other chain) token, and there have been many cases where similar but completely worthless scam tokens have been sold to investors.
What are the risks involved in DeFi?
DeFi removes most of the risks associated with traditional finance due to its radically different design. Since DeFi protocols are implemented on public blockchains and the code is open source, you need to worry less about transparency concerns, as everyone can see the code and the amount of liquidity locked in each protocol.
This doesn’t mean that DeFi is risk-free, however, but just that the risks inherent to DeFi are different from the ones in traditional finance.
Scams in DeFi
Scams are an ever-present phenomenon online, and DeFi is no exception. The most important kinds are phishing attacks, in which a scammer tricks you into giving over your private key or depositing funds into something that looks like a legitimate lending protocol or DEX. Remember, since DeFi isn’t centralized, anyone can create a blockchain address and website that looks like a legitimate protocol.
To protect against phishing attacks, always make sure that you’re visiting the correct URL and never click on links in emails from unknown addresses. Scammers can be very creative, and they will often email you saying that your funds are in danger unless you hand over your private keys. Such emails are always malicious – no one will ever ask for your private key or seed phrase unless they’re intending to steal your crypto!
One also has to be careful with any links found on social media, unless it’s 100% clear that the page is the official one of the project. Scammers often create social media pages that look identical to the official page and use them to scam people into sending them funds by promising some sort of giveaway or award.
Liquidation Risk
As previously stated, DeFi lending/borrowing protocols are usually overcollateralized, meaning that you need to lock up more value in collateral than the value of your loan. This is understandable due to the volatility of crypto, but keep in mind that the collateralization ratio (the ratio between the value of the collateral and the maximum loan value) and the value of collateral assets can change, and especially the latter can crash rapidly.
For example, when the price of Ether crashed in March 2020, a record number of loans were liquidated. To protect against this potential danger when taking out loans, you need to have enough collateral that even a rapid price crash wouldn’t lead to liquidation, which can be achieved by having multiple assets as collateral (although this isn’t yet available on all protocols). As for lending, there are fewer risks, most of which have to do with bugs or exploits in the smart contracts used by the protocol.
Protocol Risk
While DeFi protocols are typically open-source and anyone can audit the code, you can’t always be sure that someone has already gone through the trouble of doing so. It’s best to stick to the projects that have undergone thorough audits, but even then you need to keep in mind that there’s always a chance that a bug got through the checks.
One example of an exploit in DeFi was Cover, a decentralised insurance protocol. On December 28th 2020, a hacker found a bug in the code that enabled an infinite number of tokens to be minted. As the hacker used this to mint 40 quintillion tokens, the price crashed 95% in a matter of hours.
While using trusted and audited protocols can greatly reduce smart contract-related risks, it’s still a good idea to keep this in mind. As with any form of investing, never invest more than you can afford to lose. The risks on the best protocols are probably as small as the risk of a fiat monetary system collapsing (yes, this can and does happen), but they’re not completely absent. Of course, as DeFi gains more and more adoption, we can expect that there will be more and more thorough audits and the risks will become extremely small, even on newer protocols.
Last updated