14% of Maker CDPs to date have been forcibly liquidated. When this happens, the ETH held as collateral in the CDP is automatically sold at a 3% discount to pay off the CDP holder's DAI debt, and on top of this a 13% liquidation penalty is applied.
When ETH prices drop, many CDP holders can't afford to top up their CDP with ETH to prevent liquidation; but often, they don’t have enough cash to buy DAI close their CDP. So even though they may still be collateralised at over 150% (i.e. they have sufficient assets to pay back their debt), there is no way to effectively close their CDP and pay back the debt.
How can we allow these users to close their CDP without paying a hefty liquidation fee? Introducing... DAI Daddy II (Uncensored) - an autonomous platform for unwinding Maker CDPs.
What it does
v2.0 of the DAI Daddy platform builds on our work with $dai daddy, a CDP debt marketplace where sellers can list their CDP for sale and offer a "discount rate".
The new version maintains this buy/sell functionality, but adds a new primary feature: unwinding CDPs. Under this model, rather than requiring a counterparty to ensure a CDP is repaid, the new DAI Daddy smart contract withdraws collateral from the CDP, uses Kyber Network to convert this ETH to DAI, and then pays off the CDP and returns the remaining ETH collateral to the owner.
The number of withdraw/repay iterations required depends on the collateralisation ratio of the given CDP. The lower the ratio, the more iterations are required. Because this process follows an exponential curve, v1.0 of DAI Daddy is used as a backup option for CDPs whose collateralisation ratio is too low to leverage the unwinding process.
How we built it
DAI Daddy II (Uncensored) works by transferring the ownership of a MakerDAO CDP to the DaiDaddy contract which then executes the unwind process. At that point the ETH collateral in the CDP is transferred to the original owner, minus the debt owed on the CDP and any transaction fees.
The value of the CDP is calculated by looking at the underlying collateral and debt associated with the CDP. These values can be found by querying the MakerDAO Single Collateral DAI (SAI) tub contract which acts as the SAI CDP engine.
Using these values the total value of the CDP can be found by finding the difference between the underlying collateral and debt. DAI Daddy enables you to extract this remaining value once it pays off the CDP debt.
Challenges we ran into
- We realised that due to the constraints of the MakerDAO smart contract system, we needed to take the user through 3 different transaction confirmations before being able to unwind their CDP. This presented a challenge from a UX perspective, but we made it as fun and non-disruptive as possible.
- We had some issues with optimising animations for different screen sizes, which was compounded by the fact that our front-end devs are still new to Vue.js (which we’re using to make Web3 integration easier).
- Smart contracts to talk to all these systems are really hard! There are a lot of moving parts and complexity that needs to be considered.
Accomplishments that we're proud of
- Optimising for mobile devices; we updated the old website to look good on multiple screen resolutions.
- Building on the version 1.0 design to create an even more awesome DeFi product!
- Adding to the unique product narrative with a video and roadmap for future products.
- Financial maths to calculate the unwinds, max Eth withdrawal and dai conversion.
- linking all this together to talk between makerDao, Kyber and the unwinding process.
What we learned
- More about Vue.js and how it works with Web3 integration.
- Video editing and animation with Adobe Premier Pro.
- How to interact with Kyber and Maker’s smart contracts.
What's next for DAI Daddy II (Uncensored)
Optimise v2.0, do some more testing and sense-checking, and maybe launch on mainnet once everything is functioning smoothly. We also have some ideas in the pipeline for a whole range of DAI Daddy DeFi products!