• Stars
    star
    673
  • Rank 67,060 (Top 2 %)
  • Language
    Solidity
  • License
    GNU Affero Genera...
  • Created over 6 years ago
  • Updated over 1 year ago

Reviews

There are no reviews yet. Be the first to send feedback to the community and the maintainers!

Repository Details

Dai Stablecoin System

Multi Collateral Dai

Build Status

This repository contains the core smart contract code for Multi Collateral Dai. This is a high level description of the system, assuming familiarity with the basic economic mechanics as described in the whitepaper.

Additional Documentation

dss is also documented in the wiki and in DEVELOPING.md

Design Considerations

  • Token agnostic

    • system doesn't care about the implementation of external tokens
    • can operate entirely independently of other systems, provided an authority assigns initial collateral to users in the system and provides price data.
  • Verifiable

    • designed from the bottom up to be amenable to formal verification
    • the core cdp and balance database makes no external calls and contains no precision loss (i.e. no division)
  • Modular

    • multi contract core system is made to be very adaptable to changing requirements.
    • allows for implementations of e.g. auctions, liquidation, CDP risk conditions, to be altered on a live system.
    • allows for the addition of novel collateral types (e.g. whitelisting)

Collateral, Adapters and Wrappers

Collateral is the foundation of Dai and Dai creation is not possible without it. There are many potential candidates for collateral, whether native ether, ERC20 tokens, other fungible token standards like ERC777, non-fungible tokens, or any number of other financial instruments.

Token wrappers are one solution to the need to standardise collateral behaviour in Dai. Inconsistent decimals and transfer semantics are reasons for wrapping. For example, the WETH token is an ERC20 wrapper around native ether.

In MCD, we abstract all of these different token behaviours away behind Adapters.

Adapters manipulate a single core system function: slip, which modifies user collateral balances.

Adapters should be very small and well defined contracts. Adapters are very powerful and should be carefully vetted by MKR holders. Some examples are given in join.sol. Note that the adapter is the only connection between a given collateral type and the concrete on-chain token that it represents.

There can be a multitude of adapters for each collateral type, for different requirements. For example, ETH collateral could have an adapter for native ether and also for WETH.

The Dai Token

The fundamental state of a Dai balance is given by the balance in the core (vat.dai, sometimes referred to as D).

Given this, there are a number of ways to implement the Dai that is used outside of the system, with different trade offs.

Fundamentally, "Dai" is any token that is directly fungible with the core.

In the Kovan deployment, "Dai" is represented by an ERC20 DSToken. After interacting with CDPs and auctions, users must exit from the system to gain a balance of this token, which can then be used in Oasis etc.

It is possible to have multiple fungible Dai tokens, allowing for the adoption of new token standards. This needs careful consideration from a UX perspective, with the notion of a canonical token address becoming increasingly restrictive. In the future, cross-chain communication and scalable sidechains will likely lead to a proliferation of multiple Dai tokens. Users of the core could exit into a Plasma sidechain, an Ethereum shard, or a different blockchain entirely via e.g. the Cosmos Hub.

Price Feeds

Price feeds are a crucial part of the Dai system. The code here assumes that there are working price feeds and that their values are being pushed to the contracts.

Specifically, the price that is required is the highest acceptable quantity of CDP Dai debt per unit of collateral.

Liquidation and Auctions

An important difference between SCD and MCD is the switch from fixed price sell offs to auctions as the means of liquidating collateral.

The auctions implemented here are simple and expect liquidations to occur in fixed size lots (say 10,000 ETH).

Settlement

Another important difference between SCD and MCD is in the handling of System Debt. System Debt is debt that has been taken from risky CDPs. In SCD this is covered by diluting the collateral pool via the PETH mechanism. In MCD this is covered by dilution of an external token, namely MKR.

As in collateral liquidation, this dilution occurs by an auction (flop), using a fixed-size lot.

In order to reduce the collateral intensity of large CDP liquidations, MKR dilution is delayed by a configurable period (e.g 1 week).

Similarly, System Surplus is handled by an auction (flap), which sells off Dai surplus in return for the highest bidder in MKR.

Authentication

The contracts here use a very simple multi-owner authentication system, where a contract totally trusts multiple other contracts to call its functions and configure it.

It is expected that modification of this state will be via an interface that is used by the Governance layer.

More Repositories

1

multicall

Multicall: Aggregate multiple constant function call results into one
Solidity
811
star
2

awesome-makerdao

A collection of tools, documents, articles, blog posts, interviews, and videos related to MakerDAO and the Dai stablecoin.
688
star
3

developerguides

Developer guides to integrate with MakerDAO's smart contracts, SDKs, APIs, products, and partners
Shell
641
star
4

market-maker-keeper

Maker Keeper Framework: Market maker keepers for OasisDEX, EtherDelta, 0x (RadarRelay, ERCdEX), Paradex, DDEX, IDEX, Bibox, Ethfinex, GoPax, HitBTC, TheOcean, OKEX and Gate.io.
Python
452
star
5

multicall.js

Multicall.js: A JavaScript blockchain state management library for dapps
JavaScript
410
star
6

pymaker

Python API for Maker contracts
Python
193
star
7

community

Contains current and historical governance polls and executives used in the governance of the Maker Protocol. Previously contained a lot of other content which remains in the 'prior-cleanup' branch.
MDX
183
star
8

sai

Single Collateral Dai
Solidity
160
star
9

auction-keeper

Maker Keeper Framework: Keeper to participate in `flip`, `flop` and `flap` auctions in multicollateral Dai.
Python
120
star
10

arbitrage-keeper

Maker Keeper Framework: Keeper to arbitrage on OasisDEX, `join`, `exit`, `boom` and `bust`. Efficiently handles both bad debt liquidations and surplus Dai.
Python
115
star
11

spells-mainnet

Staging repo for MakerDAO weekly executive spells
Solidity
114
star
12

starknet-dai-bridge

TypeScript
98
star
13

dai.js

JavaScript
97
star
14

simple-arbitrage-keeper

Arbitrage Keeper on OasisDEX and Uniswap V1
Python
88
star
15

dss-teleport

Solidity
81
star
16

pyexchange

Python API for some cryptocurrency exchanges
Python
75
star
17

optimism-dai-bridge

Optimism Dai and upgradable token bridge
TypeScript
72
star
18

dss-proxy-actions

Set of proxy functions for MCD (using mcd-cdp-handler)
Solidity
72
star
19

dss-deploy

Set of smart contracts and bash scripts to deploy Multi collateral DAI
Solidity
66
star
20

tx-manager

Solidity contract to make multiple calls in one Ethereum transaction. Used by Maker keepers.
Makefile
66
star
21

mips

Maker Improvement Proposals (MIPs)
63
star
22

spells-goerli

Solidity
58
star
23

dss-direct-deposit

Solidity
57
star
24

integration-examples

A set of examples of how to use the DAI.js library with various purposes and configs
JavaScript
56
star
25

oracles-v2

Nix
50
star
26

bite-keeper

Maker Keeper Framework: Keeper to bite undercollateralized cups.
Python
49
star
27

dss-deploy-scripts

Shell
47
star
28

dss-flash

MakerDAO Flash Mint Module
Solidity
47
star
29

governance-portal-v2

Governance Portal V2
TypeScript
46
star
30

mips-best-practices

A collection of best practices and code samples for technical Maker Improvement Proposals (MIPs).
Solidity
44
star
31

endgame-toolkit

Smart contract modules to enable MakerDAO Endgame.
Solidity
42
star
32

dss-exec-lib

DSS Executive Spellcrafting Library Contracts
Solidity
37
star
33

market-maker-stats

Maker Keeper Framework: Set of tools to analyze market maker keepers performance.
Python
33
star
34

testchain

Start a local test chain with the MakerDAO contracts deployed on it, quickly and easily.
Shell
33
star
35

dss-conduits

Solidity
33
star
36

dss-kiln

Slow burner for protocol assets.
Solidity
33
star
37

dss-interfaces

Abstract developer interfaces to the Dai Stablecoin System core contracts.
Solidity
33
star
38

price-feed

price feed, with expiration and medianizer poke
Solidity
32
star
39

sdai

A tokenized wrapper around the DSR.
Solidity
31
star
40

univ3-lp-oracle

Solidity
31
star
41

dss-vest

Solidity
31
star
42

exchange-callees

Exchange Callee contracts for LIQ2.0 Flash Loans
Solidity
30
star
43

uniswap-price-feed

Python
30
star
44

auction-demo-keeper

JavaScript
30
star
45

evm

Shell
28
star
46

cdp-keeper

Maker Keeper Framework: Keeper to actively manage open CDPs.
Python
28
star
47

lockstake

Solidity
27
star
48

btc-market

Trade bitcoins for tokens via btc-relay
27
star
49

mkr-mcd-spec

High level KSpecification for the MCD System by Runtime Verification and Maker Foundation
Python
27
star
50

dss-gem-joins

Solidity
25
star
51

arbitrum-dai-bridge

TypeScript
25
star
52

dss-cdp-manager

Solidity
25
star
53

dss-allocator

Solidity
24
star
54

governance-portal

Governance Portal
JavaScript
24
star
55

mcd-changelog

Multi-Collateral DAI Public Releases Page
HTML
24
star
56

univ2-lp-oracle

Solidity
23
star
57

ilk-registry

A publicly-modifiable registry of ilks in the Dai Stablecoin System.
Solidity
22
star
58

scd-cdp-portal

Single-Collateral Dai CDP Portal
JavaScript
21
star
59

dss-proxy

Solidity
21
star
60

dockerized-auction-keeper

Shell
21
star
61

token-auction

Continuous Splitting Token Auction
Makefile
21
star
62

osm

Feed with 1 hour delay
Solidity
21
star
63

simplecoin1

Something to play with while we wait
Makefile
20
star
64

setzer

manipulate feeds
Shell
20
star
65

sky

Python
19
star
66

xdomain

TypeScript
19
star
67

medianizer

Returns median value of several DSValue, DSCache or other Medianizers
Solidity
18
star
68

mcd-cli

MCD Command-line interface
Shell
18
star
69

dss-bridge

18
star
70

curve-lp-oracle

Solidity
17
star
71

dai-ui

JavaScript
16
star
72

dss-crop-join

Solidity
16
star
73

petrometer

Tool which summarizes daily and total gas consumption of all transactions sent from a specified Ethereum address.
Python
16
star
74

plunger

Tool for overriding Ethereum transactions stuck in the pool
Python
16
star
75

esm

Emergency Shutdown Module
Solidity
16
star
76

governance-manual

Welcome to the Maker Operational Manual. This set of documents intends to acquaint MKR Holders with the voting process and to serve as reference material for them to consult during the day-to-day operation of the protocol.
16
star
77

median

Medianizer 2
Solidity
15
star
78

MIP21-RWA-Example

MIP21 example
Solidity
14
star
79

dss-lite-psm

14
star
80

dss-charter

Solidity
13
star
81

spells-kovan

Solidity
12
star
82

dai-cli

SCD Command-line interface
Shell
12
star
83

redeem

UI for redeeming MKR tokens
JavaScript
12
star
84

rwa-toolkit

SW Repo; Content Manager: CES-001; MIP21 Toolkit: Equipment for Off-chain Asset Backed Lending in MakerDAO
Solidity
12
star
85

dss-cron

Solidity
12
star
86

dss-chain-log

Simple way to track the mcd changelog on-chain.
Solidity
12
star
87

proxy-registry

This Registry deploys new proxy instances through DSProxyFactory and keeps a registry of owner => proxy
Solidity
12
star
88

oracle-suite

Go
11
star
89

dss-test

Solidity
11
star
90

univ2-pool-migrator

Solidity
11
star
91

megapoker

Smart contract to poke and drip
Solidity
10
star
92

token-faucet

Mostly well behaved ERC20s faucet
Solidity
10
star
93

vote-proxy

ds-chief mkr proxy voting with a hot/cold wallet
Solidity
10
star
94

scd-mcd-migration

Solidity
9
star
95

dss-darkspell

spell to conceal bug fix source and bytecode during pause delay
Solidity
9
star
96

nst

Ruby
9
star
97

protego

Solidity
9
star
98

wormhole-integration-tests

Gathers all related repos and runs a suite of integration tests using forked networks.
TypeScript
9
star
99

mcd-security

The Maker Foundation's highest priority is the security of the Maker protocol. This repository is dedicated to providing transparency to our community with respect to the results of our MCD Audits and our Bug Bounty Program results.
9
star
100

vulcan0x

SCD GraphQL API
PLpgSQL
8
star