This project implements a decentralized stablecoin system using Ethereum smart contracts. The stablecoin is designed to be pegged to USD, exogenously collateralized with wETH and wBTC, and algorithmically stabilized.
- Stablecoin Pegging:
- Pegged to $1.00 using Chainlink Price Feeds.
- Allows for the exchange of ETH and BTC to maintain the peg.
- Stability Mechanism:
- Algorithmically controlled minting based on collateral deposits.
- Ensures the system is always over-collateralized.
- Collateral:
- Accepts wETH and wBTC as collateral.
- Testing
- Robust testing with unit tests, fuzz testing, and invariant tests using Foundry
- DSCEngine.sol
- This is the core contract that handles the minting, redeeming of the stablecoin, and managing collateral.
- DecentralizedStableCoin.sol
- This contract implements the ERC20 token functionality for the stablecoin, including minting and burning capabilities.
- Unit
- Integration
- Forked
- Staging
- Fuzzing
forge test
forge coverage
and for coverage based testing:
forge coverage --report debug
- Setup environment variables
You'll want to set your SEPOLIA_RPC_URL and PRIVATE_KEY as environment variables. You can add them to a .env file, similar to what you see in .env.example.
- PRIVATE_KEY: The private key of your account (like from metamask). NOTE: FOR DEVELOPMENT, PLEASE USE A KEY THAT DOESN'T HAVE ANY REAL FUNDS ASSOCIATED WITH IT. You can learn how to export it here.
- SEPOLIA_RPC_URL: This is url of the sepolia testnet node you're working with. You can get setup with one for free from Alchemy Optionally, add your ETHERSCAN_API_KEY if you want to verify your contract on Etherscan.
- Get testnet ETH
Head over to faucets.chain.link and get some testnet ETH. You should see the ETH show up in your metamask.
- Deploy
make deploy ARGS="--network sepolia"
Foundry is a blazing fast, portable and modular toolkit for Ethereum application development written in Rust.
$ forge build
$ forge test
$ forge fmt
$ anvil
- Christos Tzaferis