Skip to content

SakshiShah29/Defi-Stablecoin

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

🏦 Foundry DeFi Stablecoin System

Screenshot 2025-06-14 at 3 11 54 PM

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.


🚀 What is DSC?

  • 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.

🧩 System Architecture

+-------------------+         +-------------------+
|                   |         |                   |
|  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.

🛠️ Getting Started

Prerequisites

  • Foundry
  • Node.js (for scripting, optional)
  • An Ethereum node or Anvil

Installation

git clone <this-repo-url>
cd foundry-defi-stablecoin
forge install

⚙️ Usage

1. Compile

forge build

2. Test

Run all tests (unit, fuzz, invariants):

forge test

3. Deploy

Deploy to a local or testnet chain:

forge script script/DeployDSC.s.sol --fork-url <YOUR_RPC_URL> --broadcast

Tip: The deployment script auto-detects the network and configures price feeds and collateral accordingly.


🧪 Testing

  • Unit Tests: test/unit/DSCEngineTest.t.sol
  • Fuzz Tests: test/fuzz/
  • Mocks: For price feeds and ERC20 tokens in test/mocks/

🏗️ Contracts Overview

  • 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.

🧰 Scripts

  • DeployDSC.s.sol: Deploys the DSC system.
  • HelperConfig.s.sol: Handles network-specific configuration for deployment.

📦 External Libraries


📝 Configuration

See foundry.toml for project configuration, remappings, and profiles.


🤝 Contributing

Pull requests and issues are welcome! Please open an issue to discuss your ideas or report bugs.


📜 License

MIT


🌟 Acknowledgements

  • Built with ❤️ by Sakshi Shah

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published