Update: The Road to Multi-Collateral Dai

March 27, 2019

Introduction

Our main focus over the past couple of months has been the development and release of the Multi-Collateral Dai (MCD) core contracts on Kovan and their interaction with the core Maker products and tools. As we work toward the full MCD mainnet release, our goal is to be as transparent as possible with the community and consistently help clarify the scope of what will be delivered over the next few months. That said, this blog post will kick off Update One of many Kovan release updates on our road to Multi-Collateral Dai. Our aim is to update the community on our progress every few weeks. These updates will cover our latest deployments and the features within them, and offer example walkthroughs and guides for you to explore on your own.

MCD is essentially a decentralized system without any operator. Once deployed onto the blockchain, it operates in an autonomous way. When building a system like this, it is crucial to get feedback—not just from internal teams, but also from the entire Maker community. Please be sure to ask us any questions you may have, provide feedback or even share your excitement with us. To do so, join our public RocketChat and leave feedback in the #product-feedback channel.

It is no secret that one of the major challenges with the immutable nature of the blockchain is releasing smart contracts. In many respects, it is more like releasing hardware than software. The releases will cover the Maker smart contracts, front-end apps, tools, and services that will all be released on a schedule. Each Kovan release will be paired with a version number referenced in the individual code repositories. The current release is v0.2.2.

In short, the process for each deployment will run through a set number of steps which put the system into a state that is ready for testing. In this first deployment, we will include a governance poll and executive vote to raise the debt ceiling from 0 on the available collateral types to allow you to draw Dai. The details for the latest release (v0.2.2) are below.

MCD CDP Portal Sneak Peek

What’s New with MCD?

Overview: The Deployed Components (v0.2.2)

For the latest Kovan testnet release, we have updated our tools to help you interact with the Multi-Collateral Dai (MCD) system. These updates include:

The MCD Contracts

Core System Contracts

Contract NameDescriptionContract Address
MCD_VATThe CDP core engine keeps track of DAI credit system accounting. 0xacdd1ee0f74954ed8f0ac581b081b7b86bd6aad9
MCD_CATThe user-facing gateway contract for liquidating (biting) CDPs.0x81f7aa9c1570de564eb511b3a1e57dae558c65b5
MCD_FLAPThe flap auction contract is responsible for buying and burning MKR when the system has a surplus.0xb6e31ab6ea62be7c530c32daea96e84d92fe20b7
MCD_FLOPThe flop auction contract is responsible for minting and selling MKR to cover bad debt.0x275ec1950d6406e3ce6156f9f529c047ea41c8ce

MKR Governance Token Contract

Contract Name DescriptionContract Address
MCD_GOVThe MKR governance token contract.0xd237d1f674c2232cef8fdc7148a59d576b67a8a3

DAI Stablecoin Contracts

Contract NameDescriptionContract Name
MCD_DAIThe DAI stablecoin contract.0xc7cc3413f169a027dccfeffe5208ca4f38ef0c40
MCD_JOIN_DAIThe DAI adapter is responsible for minting and burning DAI.0x7bb403aae0330f1acaad8f2a06ebe4b4e4784418

ETH Collateral Contracts

Contract NameDescriptionContract Address
MCD_JOIN_ETH_AThe ETH adapter is responsible for joining and exiting ETH collateral.
0x75f0660705ef0db9adde85337980f579626643af
MCD_FLIP_ETH_AThe ETH flip auction contract is responsible for selling off ETH collateral for DAI when a CDP is liquidated.
0xb88d2655aba486a06e638707fbebd858d430ac6e

Collateral 1 Contracts

Contract NameDescriptionContract Address
COL1Collateral 1 token contract.
0xc644e83399f3c0b4011d3dd3c61bc8b1617253e5
MCD_JOIN_COL1_AThe COL1 adapter is responsible for joining and exiting COL1 collateral.
0xc4e81c9690bb664d682826e3415134c23d08e7bb
MCD_FLIP_COL1_AThe COL1 flip auction contract is responsible for selling off COL1 collateral for DAI when a CDP is liquidated 0x6e8032435c84b08e30f27bfbb812ee365a095b31

To access the full list of contracts, please go here.


Getting Started with MCD

To start using and interacting with the above tools, you will need to get some Kovan ETH, COL1, COL2, COL3, COL4, COL5 and MKR. Please note that MKR holders will eventually confirm the final collateral types through a proposed vote from the Maker Risk Team. Once you have the respective Kovan tokens, you can proceed to the  guide below to go through the processes of a CDP lifecycle. This includes locking in some collateral, drawing Dai, paying back the Dai, and then unlocking the collateral.

In the guide below, everything described above will be performed using the MCD-CLI and MCD-PORTAL tools.

How to Get Kovan-ETH and K-Collateral Tokens

Getting Kovan ETH

There are many sources from which to get Kovan ETH, including:

Getting Kovan Collateral Tokens

We have deployed a special faucet that allows you to withdraw testnet collateral tokens that essentially mimic the real tokens that exist on mainnet.

K-Collateral Token Faucet Address: 0xDF31eF13A608728b6fEE5d2596Ddbb1e0d8BDe31

Before getting started, you must first setup Seth locally: https://dapp.tools/seth/

Note: You can call the gulp(address) function on it with seth. The address parameter is the address of the COL1 to COL5 collateral types we have added to this deployment.

Instructions:

  1. First, make sure that you have setup seth by following the setup instructions in the MCD-CLI README.md file: (https://github.com/makerdao/mcd-cli#installation).   
  2. In order to receive some tokens of the COL1 type, you must run the following commands in the CLI:

i. Setting the COL1 address to env variable:

$ export COL1A=0xb3844361e19ab82fce3dddd81637b85bcb554da7

ii. Setting the Faucet address to env variable:

$ export FAUCET=0xDF31eF13A608728b6fEE5d2596Ddbb1e0d8BDe31

iii. Now, you can call the gulp(address) function:

$ seth send $FAUCET 'gulp(address)' $COL1A

iv. Please verify your COL1 balance by running:

$ seth --from-wei $(seth --to-dec $(seth call $COL1A 'balanceOf(address)' $ETH_FROM)) eth

An example of the output you should be viewing when running the above command:

50.000000000000000000

That’s it! You now have some COL1 k-collateral tokens.

Note: If you would like to receive some K-MKR tokens, you would need to replace the COL1 token address with the MCD_GOV token address and follow the exact same process as above.

After you have successfully received the Kovan collateral tokens, you can continue on and explore the MCD-PORTAL and/or the MCD-CLI.

The Dai.js Library and Governance Plugin

The Dai.js library and the governance plugin tools enable you to start developing on MCD by creating loans, issuing Dai and interacting with the MKR governance system.

MCD Dai Plugin

The MCD Dai plugin allows you to interact with the Multi-Collateral Dai contracts. Follow the link below for an example of how to use the dai.js library to create and manipulatie CDPs (via the CDP Manager via a user's DSProxy) and learn how to read data from the MCD system.

Link to the Repository: https://github.com/makerdao/dai.js/tree/dev/lib/dai-plugin-mcd

A plugin for adding MKR governance support for dApps

The dai.js plugin is used to interact with the MKR governance system. The plugin makes it easy to integrate Dai governance into front-end applications, such as the Maker Governance dashboard. You can use it to vote, cast proposals, query the voting contract, create a vote proxy, and much more. Follow the below link for installation instructions and examples:

Link to the Repository: https://github.com/makerdao/dai-plugin-governance

Governance Dashboard

The Governance dashboard is a front-end interface that displays current vote proposals and sends them out to the Maker community to vote on. The dashboard is updated to the latest MCD Kovan release with the executive vote.

You can currently interact with the governance dashboard in two places:

  1. Run the local dashboard
    1. https://github.com/makerdao/governance-dashboard
  2. Staged environment
    1. https://dai-gov-staging.now.sh/?mcd=true

Multi-Collateral Dai CDP Portal

As a permissionless system of smart contracts on the blockchain, MCD can be used by anyone. There are already many teams independently developing front-ends to interact with MCD. For the purpose of the Kovan releases and trying out MCD, we will make the MCD CDP Portal available, which is currently hosted in a staging environment. The portal will be updated accordingly to support every new Kovan release. In the first release of the staging environment, you will be able to lock collateral and draw Dai.

You can check it out here: https://mcd-cdp-portal-staging.now.sh

Note: You can also setup the MCD CDP Portal on your local machine by following the instructions in this repository: https://github.com/makerdao/mcd-cdp-portal

The current deployed stage environment is in a very early work stage and is still in progress. In terms of existing functionality, it is currently limited to opening new CDPs and viewing what a CDP would look like—however, it currently uses dummy data. Over the next few weeks, more functionality will be made available, and any feedback collected will be considered for upcoming releases.  

If you are willing, you can use Usersnap, a Chrome extension,  to provide feedback on the screens displayed. See the video snippet below Usersnap simplifies communication and collaboration between developers, users, and quality assurance personnel.

Multi-Collateral Dai CLI

A command-line interface (CLI) is where you can easily interact with the Multi-Collateral Dai contracts. In the CLI, you can lock assets such as ETH and many other collateral testnet dummy tokens we have added (COL1, COL2, COL3, COL4, COL5), draw Dai against them, check your CDP position, and much more.

The following link provides you with the necessary instructions to get started with the MCD CLI: https://github.com/makerdao/mcd-cli


CDP Lifecycle Walkthrough Guide

The following instructions will guide you through an example of a CDP’s lifecycle. We will be creating a loan with COL1 type collateral (note that COL1-COL5 collateral types simply simulate ERC-20 tokens) and will then pay it back. Since the MCD-CLI is based on seth, you must first set up the required variables to start interacting with the MCD system.

Let’s get started

First,  add the required variables within terminal. Alternatively, you can add the variable in ~/.sethrc, so that you can more easily start working with the environment in the future.

The commands to set up the variables are as follows:


Once set up, you can begin to run through the CDP lifecycle using the commands noted below.

For this example, we are going to use the COL1 tokens as the first type of collateral in our CDP. Before proceeding, please check that you have already received some COL1 from the faucet. If you haven’t, please visit the ‘Getting K Collateral tokens’ section above.

Instructions

1. Connect the COL1 tokens into the COL1 adapter. Here, you must change the below value of '60' to your own value.

Run:

$ mcd --ilk=COL1-A gem join 60

Output Example:

vat 60.000000000000000000 Unlocked collateral (COL1)

ink 0.000000000000000000 Locked collateral (COL1)

ext 0.000000000000000000 External account balance (COL1)


2. Lock your COL1 collateral tokens and then draw 1 dai from VAT. Again, please don’t forget to change the below value of 60 to your own value.

Run:

$ mcd --ilk=COL1-A  frob 60 1

Example Output:
ilk  COL1-A                                                           Collateral type

urn  16Fb96a5fa0427Af0C8F7cF1eB4870231c8154B6000000000000000000000000 Urn index

ink  60.000000000000000000                                            Locked collateral (COL1)

art  1.000000000000000000                                             Outstanding debt (Dai)

printf: '58234907888888888888888889': Numerical result out of range

spot 0.000000009223372036854775807                                    Price with safety mat (USD)

rate 1.000000000000000000000000000                                    COL1 DAI exchange rate

fill 0                                                                Collateralization Ratio (%)

rap  0.000000000000000000                                             Accumulated stability fee (Dai)

dai  1.000000000000000000000000000000000000000000000                  Vat Dai

gem  0.000000000000000000

2a. Approve the MCD_JOIN_DAI to withdraw the minted Dai from your urn.

This will enable you to add MCD_JOIN_DAI and MCD_VAT variables with the respective contract addresses to the terminal.

Run:

$ seth send $MCD_VAT 'hope(address)' $MCD_JOIN_DAI

Note: This is a temporary solution until we finalize MCD dai.


3.  Withdraw Dai and send it to your ETH personal account.

Run:

$ mcd dai exit 1

Example Output:

vat 0.000000000000000000000000000000000000000000000 Vat balance

ext 1.000000000000000000 ERC20 balance

Note: When you want to pay back your debt and unlock your collateral, follow these steps again.


4. Add your Dai back into the urn.

Run:

$ mcd dai join 1

Example Output:

vat 1.000000000000000000000000000000000000000000000 Vat balance

ext 0.000000000000000000 ERC20 balance


5. Remove your Dai debt and unlock your COL1 collateral from internal system (vat).

Run:

$ mcd --ilk=COL1-A  frob -- -60 -1

Example Output:

ilk  COL1-A                                                           Collateral type

urn  16Fb96a5fa0427Af0C8F7cF1eB4870231c8154B6000000000000000000000000 Urn index

ink  0.000000000000000000                                             Locked collateral (COL1)

art  0.000000000000000000                                             Outstanding debt (Dai)

printf: '58234907888888888888888889': Numerical result out of range

spot 0.000000009223372036854775807                                    Price with safety mat (USD)

rate 1.000000000000000000000000000                                    COL1 DAI exchange rate

fill 0                                                                Collateralization Ratio (%)

rap  0                                                            Accumulated stability fee (Dai)

dai  0.000000000000000000000000000000000000000000000                  Vat Dai

gem  60.000000000000000000                                            Unlocked collateral (COL1)


6. Finally, remove your collateral COL1 token from the COL1 adapter.

Run:

$ mcd --ilk=COL1-A gem exit 60

Example Output:

vat 0.000000000000000000 Unlocked collateral (COL1)

ink 0.000000000000000000 Locked collateral (COL1)

ext 60.000000000000000000 External account balance (COL1)

After running the above commands, please confirm that you have your initial collateral (COL1) back in your wallet.

This concludes the CDP Lifecycle Walkthrough Guide! We look forward to updating you on our progress with MCD in the next couple of weeks.


Getting MakerDAO Updates

To receive updates on Maker, migrate to https://makerdao.com/en/ and in the bottom right corner of the page, you will find the “Sign up for the latest content and updates” button. Please enter you email and hit 'Subscribe'.

If you are interested in learning more about creating a product or tool that leverages the dai credit system, please get in touch with the team via Rocket.Chat.

For all other updates, follow us:

RocketChat: https://chat.makerdao.com/home

Telegram: https://t.me/makerdaoOfficial

Twitter: https://twitter.com/MakerDAO

Reddit: https://www.reddit.com/r/MakerDAO/


March 27, 2019