A decentralized stablecoin holds its peg through smart contracts rather than a bank account: users lock more crypto than the stablecoins they mint, and automated liquidations keep the system solvent when prices fall. The engineering is in the risk parameters, the oracles and the liquidation machinery, not the token.
For issuer-backed designs such as USDC, and the GENIUS Act and MiCA rules that govern them, see the stablecoin development guide. This page covers protocols where code, not an issuer, enforces the backing.
The collateralized debt position (CDP) model
MakerDAO pioneered the pattern with DAI; the protocol rebranded as Sky in 2024 and introduced USDS as an upgraded stablecoin, with DAI still in circulation. The mechanics are the same across most CDP designs:
- A user deposits collateral (for example ETH or a liquid staking token) into a vault.
- They mint stablecoins up to a limit set by the collateral ratio, say $100 of debt per $150 of collateral.
- Debt accrues a stability fee (interest), which the protocol uses as a lever: raise it to shrink supply when the coin trades below $1, lower it to grow supply when above.
- If collateral value drops below the liquidation threshold, anyone can trigger liquidation. Collateral is sold, by auction or at a discount, to repay the debt plus a penalty.
- To close the vault, the user repays the stablecoins, which are burned, and withdraws collateral.
Design components and choices
| Component | Choices | What can go wrong |
|---|---|---|
| Collateral types | Native ETH, liquid staking tokens, wrapped BTC, tokenized Treasuries, other stablecoins | Correlated crashes; depegging of wrapped or staked assets; centralization if backed by custodial assets |
| Price oracles | Chainlink-style feeds, protocol-run medianizers, time delays | Stale or manipulated prices triggering wrong liquidations or none at all |
| Liquidation engine | Dutch auctions, fixed-discount liquidations, stability pools | Keepers failing during congestion; auctions clearing near zero |
| Peg stability tools | Stability fees, savings rates, peg stability modules swapping 1:1 with other stablecoins, redemption against collateral | Reliance on centralized stablecoins via swap modules |
| Governance | Token voting, immutable parameters, algorithmic rate setting | Governance attacks; slow responses in a crisis |
| Backstop | Surplus buffer, minting governance tokens to cover bad debt | Bad debt exceeding the buffer |
Liquidations are the heart of the system
On "Black Thursday" in March 2020, ETH's sharp fall and network congestion caused some Maker auctions to clear with near-zero bids, leaving the protocol with bad debt that it covered by minting and selling governance tokens. The lesson for designers: liquidation must keep working when gas is expensive, prices gap, and keepers are overloaded. Liquity's stability-pool design, where depositors pre-commit stablecoins to absorb liquidations instantly, was one response.
Redemptions as a hard floor
Some protocols let anyone redeem one stablecoin for one dollar's worth of collateral from the riskiest vaults. This creates a firm arbitrage floor under the peg without relying on governance. Liquity's v1 LUSD used this with immutable contracts and no governance; its v2 added user-set interest rates.
Beyond CDPs
Hedged synthetic dollars
Designs like Ethena's USDe hold crypto collateral and short an equal amount of perpetual futures, so the combined position is roughly dollar-neutral, earning funding payments when they are positive. The risks are different: negative funding rates for long periods, exchange counterparty exposure, and custody arrangements off-chain. These are not decentralized in the CDP sense.
Algorithmic designs and Terra
TerraUSD (UST) held its peg through a mint-and-burn relationship with LUNA rather than collateral. In May 2022, large withdrawals and selling broke the peg; redemptions minted LUNA in huge quantities, its price collapsed, and both tokens became nearly worthless within days. Do Kwon, Terraform Labs' co-founder, later faced fraud charges in the US. Any design whose backing is a token issued by the same system is reflexive and can spiral. If you are considering one, the honest advice is: don't.
Engineering and security work
- Model the economics before writing contracts. Simulate price crashes of 30–60% in hours, oracle delays, and congestion. Agent-based simulations reveal parameter sets that fail.
- Keep the core small and well tested. Formal verification of key invariants (total debt equals the sum of vault debts, collateralization checks) is worth the cost.
- Treat oracles as critical infrastructure. Use multiple sources, sanity bounds and circuit breakers. Never rely on a single DEX spot price; see how DeFi lending platforms handle the same problem.
- Run multiple independent audits and a bug bounty. A smart contract audit is necessary but not sufficient for a system holding large collateral.
- Plan for governance attacks, such as flash-loaned voting power. Timelocks on parameter changes give users time to exit.
As a reasoned estimate, a minimal single-collateral CDP protocol is a several-month effort for three to five experienced Solidity engineers plus an economist or risk analyst, with audits and simulations adding substantial time and cost. The broader DeFi development guide covers adjacent protocol work.
Frequently asked questions
Why must decentralized stablecoins be over-collateralized?
Crypto collateral is volatile and liquidations take time. The buffer absorbs price moves between a drop and the liquidation completing, so each stablecoin stays backed.
Is a stablecoin backed by USDC in a swap module decentralized?
Partially. Its peg becomes dependent on the centralized stablecoin and its issuer's ability to freeze funds. Many protocols accept this trade-off for peg stability.
What caused TerraUSD to fail?
It had no external collateral. When holders rushed to exit, the mechanism minted ever more LUNA, destroying its value and the peg's credibility in a feedback loop.
Who runs liquidations?
Independent bots called keepers, rewarded by liquidation penalties or discounts. Designs must ensure keepers stay profitable even during extreme gas prices.