The Decentralized Stable Coin (DSC) project implements a decentralized stablecoin system that is algorithmically stabilized and pegged to the USD. The system is designed to maintain a 1:1 value with the USD while being overcollateralized with exogenous assets such as WETH and WBTC. This project includes the core smart contracts for the stablecoin, its engine, and deployment scripts.
- DecentralizedStableCoin.sol: Implements the ERC20 standard for the stablecoin, allowing minting and burning of tokens.
- DSCEngine.sol: Manages the logic for minting and redeeming the stablecoin, as well as handling collateral deposits and withdrawals.
- HelperConfig.s.sol: Provides configuration for deploying the DSC and DSCEngine contracts, including network-specific settings and mock price feeds for testing.
- MockV3Aggregator.t.sol: A mock implementation of a price aggregator for testing purposes, simulating the behavior of a price feed.
- DeployDSC.s.sol: Script for deploying the Decentralized Stable Coin and its associated DSCEngine, setting up necessary configurations and addresses.
- DSCEngineTest.t.sol: Contains unit tests for the DSCEngine contract, ensuring the functionality of collateral deposits, price feed retrieval, and error handling.
project-root/
│
├── script/
│ ├── DeployDSC.s.sol
│ └── HelperConfig.s.sol
│
├── src/
│ ├── DecentralizedStableCoin.sol
│ └── DSCEngine.sol
│
├── test/
│ ├── mocks/
│ │ └── MockV3Aggregator.t.sol
│ └── unit/
│ └── DSCEngineTest.t.sol
│
└── README.md
To get started with the project, follow these steps:
-
Clone the repository:
git clone <repository-url> cd <repository-directory>
-
Install dependencies: Ensure you have Foundry installed. Then run:
forge install
-
Compile the contracts:
forge build
-
Run tests:
forge test
To deploy the DSC and DSCEngine contracts, run the following command:
forge script script/DeployDSC.s.sol --broadcast
Once deployed, you can interact with the contracts using a web3 provider or through a frontend application. The DSCEngine
contract provides functions for depositing collateral, minting DSC, and redeeming collateral.
The project includes unit tests for the DSCEngine
contract. To run the tests, use the following command:
forge test
Contributions are welcome! If you have suggestions for improvements or find bugs, please open an issue or submit a pull request.
This project is licensed under the MIT License. See the LICENSE file for more details.
- Special thanks to the OpenZeppelin team for their ERC20 implementation and security libraries.
- Thanks to Chainlink for providing reliable price feeds.