Skip to content
@dairef

dairef

A general reference to programmable DAI

dairef

A General Reference to Programmable DAI


Purpose

Stablecoins are the settlement layer of decentralized finance. DAI, as the first decentralized, collateral-backed stablecoin, established the foundational design pattern that every subsequent stablecoin has either adopted, extended, or deliberately departed from. Its source code is not merely a product — it is a public specification. The contracts that govern DAI minting, liquidation, surplus accounting, and emergency shutdown constitute a body of work that the entire industry references, audits, and builds upon.

dairef exists to collect, preserve, and express this source code in one place.

The purpose is precise: make the canonical stablecoin reference accessible for study, peer review, and correct building. When an engineer needs to understand how collateralized debt positions work, how flash minting is safely bounded, how proxy patterns delegate authority in a multi-collateral system, or how synthetic asset protocols compose on top of stable units of account — the answer should be one repository away, not scattered across dozens of archived forks and deprecated documentation sites.


Why Source Code Collection Matters

The Problem

Stablecoin infrastructure is safety-critical financial software. A single misunderstanding of how vat.frob() adjusts collateral ratios, or how dog.bark() initiates liquidation, can result in protocol insolvency. Yet the source code for these systems is fragmented:

  • Canonical repositories are spread across multiple GitHub organizations
  • Critical dependencies (OpenZeppelin, Uniswap, Synthetix) live in separate ecosystems
  • Proxy patterns, bridge contracts, and cross-chain wrappers add layers that obscure the core logic
  • Audit reports reference specific commit hashes that may no longer be the default branch
  • Developers building new stablecoins often work from incomplete mental models because the full reference surface is not consolidated

The Solution

A reference organization that forks, organizes, and preserves the essential source code in its reviewed, audited state. Not a rewrite. Not an abstraction. The actual contracts, the actual tests, the actual deployment scripts — collected so that the full picture is visible from a single vantage point.

This is how industry standards emerge: not from specification documents alone, but from working, reviewed, battle-tested code that practitioners can read, compile, and verify.


Repository Collection

MakerDAO Core — The DAI Stablecoin System

RepositoryDescriptionLanguage
dssMulti-Collateral DAI — the core stablecoin system (Vat, Cat, Jug, Pot, Flap, Flop, Flip)Solidity
dss-flashFlash Mint Module — bounded, fee-controlled flash minting of DAISolidity
dss-proxyProxy implementation for composable DSS interactionsSolidity
dai-plugin-dcent-webD'CENT hardware wallet plugin for DAI SDKJavaScript
market-maker-keeperKeeper bot framework for MakerDAO auctions and market makingPython

DeFi Protocol References

RepositoryDescriptionLanguage
synthetixSynthetix — synthetic asset issuance protocolJavaScript/Solidity
v3-coreUniswap V3 — concentrated liquidity AMM core contractsSolidity
interfaceAave — lending and borrowing protocol interfaceTypeScript
defi-VaultDecentralized exchange with wrapped AVAX/ETH vault supportJavaScript
awesome-bondingBonding curve research and reference implementations

Smart Contract Standards and Security

RepositoryDescriptionLanguage
openzeppelin-contractsOpenZeppelin — the standard library for secure smart contract developmentSolidity
icoInitial Coin Offering reference patternsSolidity
fibFibonacci — formal verification demonstrationsSolidity

Asset Contracts and Tokenization

RepositoryDescriptionLanguage
cache-contractCACHE Gold — gold-backed token smart contractsSolidity
cache-crypto-widgetCACHE Gold purchase and redemption widgetJavaScript
cache-gold-docsCACHE Gold protocol documentation
cgt-bridgeCACHE Gold Token cross-chain bridgeSolidity
wrapped-assetsWrapped asset contract reference (WETH, WAVAX patterns)Solidity
xERC20Cross-chain ERC-20 bridging standard (ERC-7281)Solidity

Cross-Chain and Infrastructure

RepositoryDescriptionLanguage
delta0mnichainOmnichain bridge reference (Goerli to Fuji)Solidity
metaplex-program-libraryMetaplex — Solana NFT and token program libraryRust

The Case for Peer Review

Stablecoin source code occupies a unique position in software engineering. Unlike most open-source projects, where a bug results in degraded functionality, a stablecoin bug results in financial loss — potentially systemic financial loss. The MakerDAO system alone has secured billions of dollars in collateral. The contracts that govern this system must be correct not in the way that a web application must be correct, but in the way that bridge engineering must be correct: failure is not an acceptable outcome.

Peer review of stablecoin source code serves three essential functions:

1. Verification of Correctness

Every function in the DAI system has a mathematical invariant it must preserve. Vat.frob() must never allow a vault to become undercollateralized. Jug.drip() must accumulate stability fees without rounding errors that compound over time. End.cage() must freeze the system in a state where every DAI holder can redeem their proportional share of collateral. These invariants are not documented in a specification — they are expressed in the source code and enforced by the tests. Peer review is the process of verifying that the code faithfully implements these invariants.

2. Establishment of Industry Standards

When new stablecoin projects launch, they do not design from first principles. They reference existing implementations. The quality of the reference determines the quality of the derivative. If the reference code is well-organized, thoroughly tested, and accompanied by clear documentation of its design decisions, then projects that build upon it inherit those qualities. If the reference is fragmented, poorly documented, or accessible only through archaeological excavation of old commit histories, then the industry builds on sand.

dairef consolidates the reference so that builders start from solid ground.

3. Education and Institutional Knowledge

The DeFi ecosystem loses institutional knowledge rapidly. Core contributors move between projects. Documentation falls out of sync with deployed contracts. Audit reports reference code that has since been refactored. By preserving the source code in its reviewed state — not the latest commit, but the version that was audited, deployed, and battle-tested — dairef maintains the institutional knowledge that the industry needs to avoid repeating past mistakes.


Architecture of the DAI System

For reference, the core MakerDAO Multi-Collateral DAI architecture as expressed in dss:

 ┌──────────────────────────┐
│ Governance │
│ (MKR token holders) │
└────────────┬─────────────┘
│
┌──────────────────┼──────────────────┐
│ │ │
┌─────┴─────┐ ┌──────┴──────┐ ┌──────┴──────┐
│ Jug │ │ Spot │ │ End │
│ Stability │ │ Price Feed │ │ Emergency │
│ Fees │ │ + Ratios │ │ Shutdown │
└─────┬──────┘ └──────┬──────┘ └─────────────┘
│ │
┌─────┴──────────────────┴─────┐
│ Vat │
│ Central Accounting Engine │
│ (all collateral + all DAI) │
└──┬───────┬───────┬───────┬───┘
│ │ │ │
┌─────┴──┐ ┌─┴────┐ ┌┴─────┐ ┌┴──────┐
│ Join │ │ Flip │ │ Flap │ │ Flop │
│Adapters │ │Auct. │ │Auct. │ │Auct. │
│(ERC-20 ↔│ │(coll.│ │(surp.│ │(debt │
│ internal)│ │ sale)│ │ sale)│ │ sale) │
└─────────┘ └──────┘ └──────┘ └───────┘

Understanding this architecture is prerequisite to building any system that interacts with DAI — whether minting, liquidating, integrating as collateral, or building derivative instruments on top of it.


Correct Building

The phrase "correct building" is deliberate. In stablecoin development, there is a distinction between code that works and code that is correct:

  • Code that works passes its test suite today, on the current compiler version, with the current set of collateral types, under current market conditions.

  • Code that is correct preserves its invariants under all conditions the system was designed to handle, including conditions that have not yet occurred — oracle failures, governance attacks, collateral price collapses, flash loan exploits, and emergency shutdown scenarios.

The source code collected in dairef represents systems that have been subjected to this higher standard. They have survived formal verification, multiple independent audits, years of mainnet operation with billions of dollars at stake, and several black swan events. This is the code that defines what "correct" means in stablecoin engineering.

Building correctly means:

  1. Reading the reference before writing new code
  2. Understanding the invariants before modifying existing patterns
  3. Reviewing the tests to understand what edge cases the original authors anticipated
  4. Studying the audit reports to understand what edge cases they missed
  5. Preserving the design decisions that protect users, even when they add complexity

Licensing

Each repository in the dairef collection retains the license of its upstream source. The predominant licenses are:

LicenseRepositories
AGPL-3.0dss, dss-flash, dss-proxy, market-maker-keeper
MITopenzeppelin-contracts, defi-Vault, xERC20, cache-contract, wrapped-assets
GPL-3.0synthetix

Consult the LICENSE file in each individual repository for the authoritative terms.


Related Work

ProjectRelationship
MakerDAOUpstream source for dss, dss-flash, dss-proxy
OpenZeppelinUpstream source for contract standards
bankonmeSovereign banking infrastructure (bankonOS)
Professor-CodephreakbankonOS source and bankonHEADs preservation
CACHE GoldUpstream source for gold-backed token contracts
UniswapUpstream source for v3-core AMM
SynthetixUpstream source for synthetic asset protocol
AaveUpstream source for lending protocol interface

Complete Repository Index

All 22 repositories collected under github.com/dairef for quick reference and machine ingestion.

#RepositoryDescriptionLicenseFork
1dssDai Stablecoin System — Multi-Collateral DAI core (Vat, Jug, Spot, Dog, Flap, Flop)AGPL-3.0yes
2dss-flashMakerDAO Flash Mint Module — bounded, fee-controlled DAI flash mintingAGPL-3.0yes
3dss-proxyProxy implementation of DAI DSS — composable vault interactionsAGPL-3.0yes
4dai-plugin-dcent-webD'CENT hardware wallet plugin for dai.js in browser environmentsMITyes
5market-maker-keeperKeeper bot framework — OasisDEX, EtherDelta, 0x, Paradex, DDEX, IDEX, Bibox, Ethfinex, GoPax, HitBTC, OKEX, Gate.ioAGPL-3.0yes
6synthetixSynthetix — synthetic asset issuance protocol smart contractsMITyes
7v3-coreUniswap V3 — concentrated liquidity automated market maker core contractsBSL-1.1yes
8interfaceAave — lending and borrowing protocol interfaceyes
9defi-VaultDecentralized exchange — deposit wrapped AVAX/ETH, supply wrappedETH to Compoundyes
10openzeppelin-contractsOpenZeppelin — the standard library for secure smart contract developmentMITyes
11cache-contractCACHE Gold Token — gold-backed ERC-20 smart contractsMITyes
12cache-crypto-widgetCACHE Gold purchase widget — buy CGT using any token at Chainlink XAU price + marginMITyes
13cache-gold-docsCACHE Gold smart contract documentationyes
14cgt-bridgeCACHE Gold Token cross-chain bridge contractsyes
15wrapped-assetsWrapped asset contracts — WAVAX based on WETH patternGPL-3.0yes
16xERC20Cross-chain ERC-20 bridging standard (ERC-7281)MITyes
17delta0mnichainOmnichain bridge reference — Goerli to Fuji exampleyes
18metaplex-program-libraryMetaplex — Solana NFT and token program library (Rust)yes
19icoJincor ICO — initial coin offering reference smart contractsyes
20fibFibonacci — Solidity formal verification demonstrationAGPL-3.0yes
21awesome-bondingCurated list of token bonding curve code and resourcesyes
22PAIPayment gateway for agentic economy at scaleno

Collection by Category

MakerDAO / DAI Core: dss, dss-flash, dss-proxy, dai-plugin-dcent-web, market-maker-keeper

DeFi Protocols: synthetix, v3-core (Uniswap), interface (Aave), defi-Vault

Smart Contract Standards: openzeppelin-contracts, ico, fib

Gold-Backed Assets: cache-contract, cache-crypto-widget, cache-gold-docs, cgt-bridge

Cross-Chain / Bridging: xERC20, delta0mnichain, wrapped-assets, metaplex-program-library

Research / Education: awesome-bonding

Original Work: PAI (payment gateway for agentic economy at scale)


Contributing

dairef is a reference collection. Contributions should:

  • Add forks of audited, deployed stablecoin or DeFi infrastructure source code
  • Preserve the upstream commit history and license
  • Not modify the source code from its audited state
  • Include context (in issues or discussions) about why the addition is relevant to stablecoin peer review

If you have identified source code that belongs in this collection, open an issue describing the repository, its relevance to stablecoin infrastructure, and its audit history.


The quality of financial infrastructure is determined by the quality of its reference implementations.

Collect the source. Review the source. Build correctly.

github.com/dairef

Pinned Loading

  1. dss-flashdss-flashPublic

    Forked from sky-ecosystem/dss-flash

    MakerDAO Flash Mint Module

    Solidity 1

  2. dssdssPublic

    Forked from sky-ecosystem/dss

    Dai Stablecoin System

    Solidity

  3. dss-proxydss-proxyPublic

    Forked from sky-ecosystem/dss-proxy

    proxy implementation of dai dss

    Solidity

  4. defi-Vaultdefi-VaultPublic

    Forked from tethercoin/defi-Vault

    decentralized exchange/ deposit wrapped Avax /ETH. supply wrappedEth to Compound

    JavaScript

  5. openzeppelin-contractsopenzeppelin-contractsPublic

    Forked from OpenZeppelin/openzeppelin-contracts

    OpenZeppelin Contracts is a library for secure smart contract development.

    JavaScript

  6. synthetixsynthetixPublic

    Forked from tethercoin/synthetix

    Synthetix Solidity smart contracts

    JavaScript 1

Repositories

Showing 10 of 22 repositories

People

This organization has no public members. You must be a member to see who’s a part of this organization.

Top languages

Loading…

Most used topics

Loading…