Welcome to the Decentralized Stable Coin (DSC) System — a minimal, exogenously collateralized, algorithmic stablecoin protocol built with Foundry! This project is inspired by DAI, but with a twist: no governance, no fees, and only WETH & WBTC as collateral.
- Pegged to $1.00: Maintains a soft peg to the US Dollar using Chainlink price feeds.
- Exogenous Collateral: Only accepts external crypto assets (WETH, WBTC) as collateral.
- Algorithmic Stability: Overcollateralized and managed by smart contracts, not humans.
- No Governance: Purely code-driven, no admin keys or DAOs.
+-------------------+ +-------------------+
| | | |
| User Wallets | <-----> | DSCEngine.sol |
| | | |
+-------------------+ +-------------------+
|
v
+---------------------------+
| DecentralizedStableCoin |
| .sol |
+---------------------------+
|
v
+---------------------------+
| Chainlink Oracles |
+---------------------------+
- DSCEngine.sol: The protocol's brain. Handles collateral, minting, redemption, and health checks.
- DecentralizedStableCoin.sol: The ERC20 implementation of the stablecoin (DSC).
- OracleLib.sol: Ensures price feeds are fresh and reliable.
git clone <this-repo-url>
cd foundry-defi-stablecoin
forge installforge buildRun all tests (unit, fuzz, invariants):
forge testDeploy to a local or testnet chain:
forge script script/DeployDSC.s.sol --fork-url <YOUR_RPC_URL> --broadcastTip: The deployment script auto-detects the network and configures price feeds and collateral accordingly.
- Unit Tests:
test/unit/DSCEngineTest.t.sol - Fuzz Tests:
test/fuzz/ - Mocks: For price feeds and ERC20 tokens in
test/mocks/
- src/DSCEngine.sol: Core logic for collateral, minting, redemption, and liquidation.
- src/DecentralizedStableCoin.sol: ERC20 stablecoin with mint/burn restricted to DSCEngine.
- src/libraries/OracleLib.sol: Chainlink oracle safety checks.
- DeployDSC.s.sol: Deploys the DSC system.
- HelperConfig.s.sol: Handles network-specific configuration for deployment.
See foundry.toml for project configuration, remappings, and profiles.
Pull requests and issues are welcome! Please open an issue to discuss your ideas or report bugs.
MIT
- Built with ❤️ by Sakshi Shah