A full-stack decentralized exchange built with React, Node.js, TypeScript, and smart contracts on Monad testnet.
- Real-time Trading Interface - Live orderbook, charts, recent trades
- Portfolio Management - Deposit/withdraw tokens, view balances
- Socket.IO Integration - Real-time updates for orders, trades, and balances
- Responsive Design - Modern UI with TailwindCSS and Radix UI
- Wallet Integration - Connect with Web3 wallets (EIP-155)
- Blockchain Integration - Ethers.js v6 with WebSocketProvider for Monad testnet
- Event Processing - Real-time subscription to smart contract events
- Database - MongoDB for normalized data storage
- REST API - HTTP endpoints for orders, trades, pairs
- Socket.IO Server - Real-time data streaming to frontend
- Event Backfill - Automatic backfill of missed events on startup
- Vault - Token deposit/withdrawal management
- Orderbook - Order matching and trade execution
- Pair Registry - Trading pair management
- Fee Manager - Trading fee collection
┌─────────────────┐ ┌──────────────────┐ ┌─────────────────┐
│ Monad Testnet │◄──►│ Event Processor │◄──►│ MongoDB │
│ (WebSocket) │ │ │ │ │
└─────────────────┘ └──────────────────┘ └─────────────────┘
│
▼
┌──────────────────┐
│ Socket.IO Server│◄──► Frontend Clients
│ + REST API │
└──────────────────┘
realDex/
├── frontendV2/ # React frontend (current)
│ ├── src/ # Source code
│ │ ├── components/ # UI components
│ │ ├── pages/ # Route pages
│ │ └── lib/ # Utilities
├── backendV2/ # Node.js backend (current)
│ ├── index.js # Main backend server
│ ├── abis/ # Contract ABIs
│ └── ... # Other backend files
├── blockchainv3/ # Smart contracts
│ ├── contracts/ # Solidity contracts
│ ├── scripts/ # Deployment scripts
│ └── deployments.json # Contract addresses
- Node.js 18+
- npm or pnpm
- MongoDB instance
- Monad testnet access
git clone <repository-url>
cd realDex
# Install frontend dependencies
cd frontendV2
npm install
# Install backend dependencies
cd ../backendV2
npm install
# Install smart contract dependencies
cd ../blockchainv3
npm installcd backendV2
cp .env.example .envEdit .env with your values:
MONGO_URI=mongodb://localhost:27017/orderbook
WS_RPC=wss://testnet-rpc.monad.xyz
ORDERBOOK_ADDR=0x4A8948D81B9e277b0DA9070E6D02816d0E36F18A
PAIRREG_ADDR=0xB1d7C0E3a1278D83a95Ff98e821f73EEe836d666
PRIVATE_KEY=your_private_key- Start your MongoDB instance (local or cloud)
cd backendV2
npm run devcd frontendV2
npm run devcd blockchainv3
npm run dev- Frontend: http://localhost:8080
- Backend API: http://localhost:3001
- Socket.IO: ws://localhost:3001
GET /api/pairs- Get trading pairsGET /api/orders- Get ordersGET /api/trades- Get recent trades
orderPlaced- New order createdorderMatched- Order matchedorderCancelled- Order cancelledpairAdded- New trading pair added
cd frontendV2
npm run dev # Start development server
npm run build # Build for productioncd backendV2
npm run dev # Start development server
npm run build # Build for production
npm start # Start production servercd blockchainv3
npm run compile # Compile contracts
npm run deploy # Deploy to testnet
npm run test # Run tests- Deposit Tokens - Deposit USDC/WETH to vault for trading
- Withdraw Tokens - Withdraw available tokens to wallet
- Balance Tracking - View available and locked balances
- Real-time Updates - Live balance updates via Socket.IO
- Orderbook - Live bid/ask orders with real-time updates
- Charts - Price and depth charts
- Trade Form - Place buy/sell orders
- Recent Trades - Activity feed
- Smart Contract Audits - Contracts follow OpenZeppelin standards
- Access Control - Role-based permissions for critical functions
- Input Validation - Comprehensive validation on all inputs
- Error Handling - Graceful error handling throughout
cd backendV2
npm run build
npm startcd frontendV2
npm run build
# Deploy dist/ to your hosting provider- 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 issues and questions:
- Check the documentation
- Search existing issues
- Create a new issue with detailed information
- Price feed integration
- Advanced order types (limit, stop-loss)
- Mobile app
- Multi-chain support
- Governance token
- Advanced analytics
- API rate limiting
- Caching layer
- Monitoring and alerting