The StableCoin Project is a decentralized stablecoin pegged to the USD, offering an algorithmic approach to maintaining stability. Users can mint the DSC token using Bitcoin or Ethereum as collateral, ensuring transparency and decentralization.
- Minting: Users can mint DSC tokens by depositing sufficient collateral.
- Burning: DSC tokens are burned when collateral is redeemed or liquidated.
- Supported Collateral: Bitcoin and Ethereum.
- Health Factor: Users must maintain a health factor above 1e18 to avoid liquidation.
- Liquidation Incentives: Liquidators receive 10% of the liquidated user's collateral.
- Deposit collateral.
- Redeem collateral.
- Mint DSC tokens.
- Calculate health factors.
- Liquidate undercollateralized users.
Ensure you have the following tools installed:
-
Clone the repository and install dependencies:
git clone <repository_url> cd StableCoinProject
-
Configure your
.env
file with network details, private keys, and RPC URLs.
- Deploy the
DecentralizedStableCoin.sol
contract:forge create --rpc-url <rpc_url> --private-key <private_key> src/DecentralizedStableCoin.sol
- Deploy the
DSCEngine.sol
contract:forge create --rpc-url <rpc_url> --private-key <private_key> src/DSCEngine.sol
Users can deposit collateral to secure their DSC tokens by interacting with the depositCollateral()
function:
cast send <DSCEngine_address> "depositCollateral(address collateralType, uint256 amount)" --rpc-url <rpc_url> --private-key <private_key>
Users can mint DSC tokens by interacting with the mint()
function:
cast send <DSCEngine_address> "mint(uint256 amount)" --rpc-url <rpc_url> --private-key <private_key>
Use the redeem()
function to withdraw collateral:
cast send <DSCEngine_address> "redeem(uint256 amount)" --rpc-url <rpc_url> --private-key <private_key>
Liquidators can call the liquidate()
function:
cast send <DSCEngine_address> "liquidate(address user)" --rpc-url <rpc_url> --private-key <private_key>
.
├── contracts
│ ├── DecentralizedStableCoin.sol # ERC20 token contract
│ ├── DSCEngine.sol # Engine contract
├── test
│ ├── stablecoin.test.js # Test cases
├── README.md # Project documentation
We welcome contributors to the StableCoin Project!
- Fork the repository.
- Create a new branch.
- Submit a pull request with your changes.
This project is licensed under the MIT License. See LICENSE
for details.