Decentralized Finance – DeFi – is a blooming new field in blockchain. The aim is simple: remove middlemen and regulators from finance.
In this post, we'll focus on loans and stablecoins through MakerDAO. Next, we'll look at how to get the money to work for us.
MakerDAO and CDP
A CDP is a collateralized debt position. A CDP lets you take a loan and put down collateral guaranteeing you'll repay it.
If you don't, your collateral can be liquidated – sold to others at a discount – to repay your debt. It's like mortgaging your cryptocurrency.
DAI and MKR
MakerDAO is the organization behind the DAI stablecoin. DAI has a ratio of 1:1 with USD.
Unlike other stablecoins, DAI is not based on fiat deposits in a bank somewhere. It is instead generated by putting ether into a CDP smart contract. This deposit then lets you borrow the DAI.
As you repay your DAI loan with 0.5% per year interest, you get your deposit back. The deposit is turned into your loan repayment – liquidated – if the price of ether drops too much.
The price data is provided by several trusted oracles. These are secret, external data providers known only to the Oracle team at MakerDAO. They are also the system's biggest weakness.
If you start approaching the liquidation threshold, you can repay some DAI or add more ether into the CDP to shift the balance slightly to your favor. We'll see an example of this in the step by step process below.
Additionally, there is the MKR token. MKR is the shareholder token of the MakerDAO network. It's what's used to get extra liquidity when not enough collateral is in the system to repay everything. It should be noted that this wasn't needed even during the 94% drop of ether price in 2018, making DAI the most stable of stablecoins out there.
The purpose of MakerDAO and DAI
Effectively, this lets you:
- Get a loan in DAI (dollars) based on your crypto holdings
- Use the DAI in any way you want
- Repay the DAI when you're ready to get your collateral back
If the value of ether rises, you repay the DAI and have more valuable ether. Alternatively, use the rising value to produce more DAI. If the value of ether drops, you're safe for as long as your ratio is above 150%.
Suppose ether is at 120 USD. Suppose also that you generated 60 DAI. Your collateralization ratio is 200% (120/60).
If the price of ether falls to 90 USD, then your collateral is at risk of being liquidated. The first user who notices you're under 150% can trigger this liquidation procedure. They get a small reward to incentivize third parties to find bad loans. Your loan is then liquidated, penalized, and the rest of your collateral is returned to you.
Ok, let's try making some DAI.
We'll use MetaMask in this example. Unlock your wallet which has some ether in it. You'll see the following screen:
The screen will list how much ether you have in the unlocked wallet. Other assets important to MakerDAO, DAI and MKR, will be listed as well.
Note: Because DAI and MKR are ERC20 tokens, there is a checkmark next to them in the “Unlock” column. Clicking these makes it possible for MakerDAO's smart contracts to manage these assets for you. This is important for using the system, so it's best to unlock them now, you'll probably have to do it later anyway. This will require two transactions.
Let's open a CDP now with our 0.9 ether. Never collateralize all your ether – you'll need some for transaction costs. Click “Open CDP”.
You can now choose how much ether to deposit and how much DAI to generate. Let's choose a safe collateralization ratio od 217% by generating 50 DAI for 0.9 eth.
The next screen will tell you that CDPing is a process of 7 automated transactions. Feel free to expand that tab to find out what those transactions are and why they are necessary, we won't go over them here. Confirm and wait a bit for everything to go through.
Once done, you will be able to inspect the transaction linked on the confirmation dialog. There you'll see what happened and how much it cost in ether and gas.
We now have our CDP.
The screen lets us perform one of four actions:
- Deposit lets us “top up” the CDP with more ether. This increases the collateralization ratio helping avoid liquidation. It also lets us generate more DAI.
- Withdraw lets us withdraw ether to the point of 150% collateralization. We can withdraw less than that, of course, if we urgently need some, but each withdrawal brings us closer to the ratio's 150% limit.
- Payback lets us cover the loan in part or in full by paying back the borrowed DAI. Paying back in part lets us increase collateralization ratio, just like depositing Eth would. Paying back in full lets us close the CDP.
- Generate lets us generate more DAI, reducing the collateralization ratio. Extra useful when ether rises in price dramatically – lets us extract more DAI for the same amount of eth!
At this point, the DAI is in our account. This is evident in the right hand side of the screen. It can also be easily verified by checking MetaMask.
We can now use the DAI in exchanges that support it, purchase goods online, speculate on other cryptos, or any number of things.
Note: some time in the near future, MakerDAO will enable collateral in multiple assets. You will no longer need to use ether exclusively.
Paying back the DAI
To close a CDP and get your collateral back, you pay back the full amount. Click Payback but… whoops! What's this red warning??
The MakerDAO system lives by being additionally collateralized as a whole with the MKR token. As such, it charges for the “stability fee” in MKR tokens or alternatively in DAI.
When paying back any amount of generated DAI, you need to also cover this stability fee. But if you're paying with all the DAI you have and you have no MKR, you cannot close your CDP! This is a UX nightmare as it's not made clear when creating a CDP. I would recommend the MakerDAO UX team address this urgently.
Thankfully, there is a workaround in times of crisis. If the price of ether starts dropping rapidly and you're at risk of liquidation, you can pay back part of your DAI and choose to pay the fee in DAI.
This way you increase your ratio and buy yourself some time, in addition to significantly reducing your exposure. The remaining loan is now small, so the liquidation will be much smaller too on the off chance it actually occurs.
Let's see how a partial payback would work.
Well, can't argue with that ratio! The chances of liquidation are extremely low. Ether would have to go down to 33 USD!
Inspecting the DAI balance, we also see that this stability fee cost us less than seven millionths of a DAI.
DAI dust, we call this. Still enough to create trouble – so always make sure you have either some MKR dust, or some DAI dust, in addition to what you're paying back.
Closing a CDP
Okay, now let's top up our account from elsewhere with some MKR or DAI to cover this dust. Decentralized exchanges like Idex, OasisDex, Kyber and similar work pretty well and need no verification.
I'll use DAI to repay the remaining 20 DAI in full and close the CDP.
A few transaction confirmations later our CDP will be empty. It won't be gone, however!
You can still use it – it's like you have your own personal platform for loans open now and can reuse it at will. To totally delete it, you can click the “Close CDP” button at the top. This will again inform you that you need to pay back the outstanding DAI.
Already done, so closing is cleared!
So, what happens when the collateralization ratio drops beneath 150%?
If you're the debtee, you are exposed to liquidation. 13% of your collateral will be taken as a penalty, the rest will be liquidated – sold at a discount – into whatever is needed to pay back the debt.
If you're a bystander who notices someone's defaulting loan, however, you can use this to your advantage through certain bots, but that's outside the scope of this article.
For more information about liquidation, this excellent FAQ is a gold mine.
Next we'll explore how to take proper advantage of the generated DAI by loaning it to others and automatically generating interest on it.