This project implements a decentralized, algorithmic stablecoin system on Ethereum. Users can deposit WETH and WBTC as collateral to mint DSC, a token pegged to USD.
- Pegged to USD: DSC maintains a 1:1 peg to the US Dollar.
- Exogenous Collateral: Only WETH and WBTC are accepted as collateral.
- Algorithmic Stability: No governance or fees; stability is enforced by smart contract logic.
- Overcollateralization: The system ensures all DSC is backed by more collateral than its value.
DSCEngine: Core logic for minting, redeeming, collateral management, and liquidation.DecentralizedStableCoin: ERC20 implementation of DSC, with mint/burn restricted to DSCEngine.HelperConfig: Network configuration and mock deployment for local testing.OracleLib: Chainlink price feed safety checks.MockV3Aggregator: Chainlink price feed mock for tests.
- Foundry
- Node.js (for some scripts)
- Git (with submodules)
git clone --recurse-submodules <repo-url>
cd stablecoin
forge installforge buildforge test --coverageDeploy contracts using the provided scripts:
forge script script/DeployDSC.s.sol --rpc-url <your_rpc_url> --broadcast- Unit tests:
test/unit/ - Fuzz/invariant tests:
test/fuzz/ - Coverage report:
coverage.txt
src/: Main contractsscript/: Deployment and config scriptstest/: Unit and fuzz testslib/: External dependencies (OpenZeppelin, Chainlink, Forge Std)
Pull requests and issues are welcome! Please:
- Write clear commit messages
- Add/modify tests for new features
- Follow Solidity best practices
MIT