A modern decentralized lending platform frontend built with Next.js, Tailwind CSS, and Wagmi. This MVP provides a complete interface for lending, borrowing, and managing collateral with dynamic health metrics.
- Dashboard: View lending pools with liquidity, APY, and utilization metrics
- Account Management: Monitor collateral, debt, health factor, and risk score
- Lending Actions: Deposit, withdraw, borrow, and repay assets
- Transaction History: Complete transaction history with Etherscan links
- Wallet Integration: Connect with MetaMask, WalletConnect, and other Web3 wallets
- Responsive Design: Mobile-first design with dark mode support
- Framework: Next.js 14 with App Router
- Styling: Tailwind CSS v4
- Web3: Wagmi + Viem for Ethereum integration
- UI Components: shadcn/ui
- Icons: Lucide React
- TypeScript: Full type safety
- Node.js 18+
- npm or yarn
- MetaMask or compatible Web3 wallet
-
Clone the repository: ```bash git clone cd defi-lending-dapp ```
-
Install dependencies: ```bash npm install
yarn install ```
- Set up environment variables: ```bash cp .env.example .env.local ```
Add your environment variables: ```env NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID=your_walletconnect_project_id ```
- Run the development server: ```bash npm run dev
yarn dev ```
- Open http://localhost:3000 in your browser.
``` ├── app/ # Next.js App Router pages │ ├── account/ # Account management page │ ├── actions/ # Lending actions page │ ├── history/ # Transaction history page │ ├── layout.tsx # Root layout with providers │ └── page.tsx # Dashboard page ├── components/ # Reusable UI components │ ├── ui/ # shadcn/ui components │ ├── account-stats.tsx # Account metrics display │ ├── action-modal.tsx # Action forms modal │ ├── event-table.tsx # Transaction history table │ ├── navbar.tsx # Navigation component │ ├── pool-card.tsx # Pool display cards │ └── wallet-connect.tsx # Wallet connection ├── hooks/ # Custom React hooks │ ├── use-account-data.ts # Account data fetching │ ├── use-contract-actions.ts # Contract interaction hooks │ ├── use-pool-data.ts # Pool data fetching │ └── use-transaction-history.ts # Transaction history ├── lib/ # Utility libraries │ ├── utils.ts # General utilities │ └── wagmi.ts # Wagmi configuration └── providers/ # React context providers └── wagmi-provider.tsx # Wagmi + TanStack Query setup ```
- Displays lending pools with real-time metrics
- Shows liquidity, APY, and utilization rates
- Quick deposit actions for each pool
- Total collateral and debt overview
- Health factor with color-coded progress bar
- Risk score (0-100) with status indicators
- Detailed asset breakdowns
- Modal forms for deposit, withdraw, borrow, repay
- Asset selection with balance display
- Real-time transaction feedback
- Quick stats overview
- Complete transaction history table
- Etherscan integration for transaction details
- Status tracking (completed, pending, failed)
- Transaction type filtering
This MVP uses mock data for demonstration. The following hooks simulate contract interactions:
useDeposit()
- Deposit assets to earn yielduseWithdraw()
- Withdraw deposited assetsuseBorrow()
- Borrow against collateraluseRepay()
- Repay borrowed assetsuseAccountData()
- Fetch account metricsusePoolData()
- Fetch pool information
- Push your code to GitHub
- Connect your repository to Vercel
- Add environment variables in Vercel dashboard
- Deploy automatically on push
```bash npm run build npm start ```
Variable | Description | Required |
---|---|---|
NEXT_PUBLIC_WALLETCONNECT_PROJECT_ID |
WalletConnect project ID | Yes |
To connect with real smart contracts:
- Replace mock hooks in
hooks/use-contract-actions.ts
- Add contract ABIs and addresses
- Implement real contract calls using Wagmi
- Update data fetching hooks with actual contract reads
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
MIT License - see LICENSE file for details.
For questions or issues, please open a GitHub issue or contact the development team.