Skip to content

ProngsDev/DSC_FE

Repository files navigation

DSC Protocol Frontend

A modern, responsive frontend for the Decentralized Stable Coin (DSC) protocol built with Next.js, TypeScript, and Web3 technologies.

πŸ”— Complete System

This repository contains the frontend application for the DSC Protocol. For the complete system:

Component Repository Description
Smart Contracts DSC Core protocol logic, deployment scripts, and tests
Frontend Application DSC_FE Next.js web interface for interacting with the protocol (this repository)

πŸ’‘ Quick Start: Deploy the smart contracts from the DSC repository first, then run this frontend to interact with your deployed contracts.

Features

  • πŸ”— Wallet Integration: Connect with MetaMask and other wallets via RainbowKit
  • πŸ’° Collateral Management: Deposit and redeem WETH/WBTC collateral
  • πŸͺ™ DSC Operations: Mint and burn DSC stablecoins
  • πŸ“Š Health Factor Monitoring: Real-time health factor tracking with warnings
  • ⚑ Liquidation Interface: Liquidate undercollateralized positions
  • πŸ“ˆ Protocol Statistics: Live price feeds and protocol metrics
  • πŸŒ™ Dark Mode: Full dark/light theme support
  • πŸ“± Responsive Design: Works on desktop and mobile devices

Screenshots

Landing Page

Landing Page Clean, modern landing page introducing the DSC Protocol

Wallet Connection

Landing with Wallet Seamless wallet integration with RainbowKit

Dashboard

Dashboard Comprehensive dashboard showing portfolio overview, health factor, and protocol statistics

Collateral Management

Collateral Management Intuitive interface for depositing and redeeming WETH/WBTC collateral

DSC Management

DSC Management Simple DSC minting and burning interface with real-time health factor monitoring

Analytics

Analytics Detailed protocol analytics and performance metrics

Tech Stack

  • Framework: Next.js 15 with App Router
  • Language: TypeScript
  • Styling: Tailwind CSS v4
  • Web3: Wagmi v2, Viem, RainbowKit
  • State Management: Zustand, TanStack Query
  • UI Components: Headless UI, Heroicons
  • Notifications: React Hot Toast

Prerequisites

Before running the frontend, ensure you have the DSC protocol smart contracts deployed locally:

  1. Clone and set up the smart contracts repository:

    git clone https://github.com/ProngsDev/DSC.git
    cd DSC
    make install
  2. Start Anvil blockchain:

    make anvil
  3. Deploy contracts (in a new terminal):

    make deploy-local
    make export-frontend
  4. Get test tokens:

    make deposit-local

Getting Started

  1. Install dependencies:

    npm install
  2. Configure environment:

    • Copy .env.local and update contract addresses if needed
    • The default addresses should work with make deploy-local
  3. Start the development server:

    npm run dev
  4. Open the application:

    • Navigate to http://localhost:3000
    • Connect your wallet (use the test account or import the private key)
    • Start using the DSC protocol!

Wallet Setup

Add Anvil Network to MetaMask

Import Test Account

Use the default Anvil test account:

  • Private Key: 0xac0974bec39a17e36ba4a6b4d238ff944bacb478cbed5efcae784d7bf4f2ff80
  • Address: 0xf39Fd6e51aad88F6F4ce6aB8827279cffFb92266

Usage Guide

1. Deposit Collateral

  • Select WETH or WBTC
  • Enter amount to deposit
  • Approve token spending (first time)
  • Confirm deposit transaction

2. Mint DSC

  • Enter DSC amount to mint
  • Ensure sufficient collateral (health factor > 1.0)
  • Confirm mint transaction

3. Monitor Health Factor

  • Keep health factor above 1.0 to avoid liquidation
  • Yellow warning appears below 1.1
  • Red alert appears below 1.0 (liquidatable)

4. Burn DSC & Redeem Collateral

  • Burn DSC to reduce debt
  • Redeem collateral when health factor allows
  • Maintain minimum collateralization ratio

5. Liquidate Positions

  • Find users with health factor < 1.0
  • Cover their debt to earn 10% bonus
  • Help maintain protocol stability

Project Structure

src/
β”œβ”€β”€ app/                 # Next.js app router
β”œβ”€β”€ components/          # React components
β”‚   β”œβ”€β”€ providers/       # Context providers
β”‚   β”œβ”€β”€ Dashboard.tsx    # Main dashboard
β”‚   β”œβ”€β”€ Header.tsx       # Navigation header
β”‚   β”œβ”€β”€ UserPortfolio.tsx # Portfolio overview
β”‚   β”œβ”€β”€ CollateralManager.tsx # Collateral operations
β”‚   β”œβ”€β”€ DSCManager.tsx   # DSC mint/burn
β”‚   β”œβ”€β”€ LiquidationMonitor.tsx # Liquidation interface
β”‚   └── ProtocolStats.tsx # Protocol statistics
β”œβ”€β”€ lib/
β”‚   β”œβ”€β”€ hooks/           # Custom React hooks
β”‚   β”œβ”€β”€ abis/            # Contract ABIs
β”‚   β”œβ”€β”€ config.ts        # Wagmi configuration
β”‚   └── utils.ts         # Utility functions
└── types/               # TypeScript definitions

Development

Available Scripts

  • npm run dev - Start development server
  • npm run build - Build for production
  • npm run start - Start production server
  • npm run lint - Run ESLint

Environment Variables

Key environment variables in .env.local:

NEXT_PUBLIC_CHAIN_ID=31337
NEXT_PUBLIC_RPC_URL=http://localhost:8545
NEXT_PUBLIC_DSC_ADDRESS=0x...
NEXT_PUBLIC_DSC_ENGINE_ADDRESS=0x...
NEXT_PUBLIC_WETH_ADDRESS=0x...
NEXT_PUBLIC_WBTC_ADDRESS=0x...

Troubleshooting

Common Issues

  1. "Contract not deployed":

    • Ensure Anvil is running
    • Run make deploy-local in DSC directory
    • Check contract addresses in .env.local
  2. "Insufficient funds":

    • Run make deposit-local to get test tokens
    • Ensure you're using the correct test account
  3. "Transaction failed":

    • Check health factor before minting
    • Ensure sufficient allowances
    • Verify network connection
  4. "Wallet not connecting":

    • Add Anvil network to MetaMask
    • Import test account private key
    • Refresh page and try again

Reset Local State

If you encounter persistent issues:

  1. Reset Anvil blockchain:

    # Stop Anvil (Ctrl+C) and restart
    make anvil
  2. Redeploy contracts:

    make deploy-local
    make export-frontend
  3. Clear browser cache and reconnect wallet

Contributing

  1. Fork the repository
  2. Create a feature branch
  3. Make your changes
  4. Add tests if applicable
  5. Submit a pull request

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages