A modern React frontend with MetaMask integration for managing Hyperliquid perpetual trading positions, orders, deposits, and withdrawals.
- π MetaMask Wallet Integration - Connect and manage your wallet
- π Real-time Dashboard - View account balance, positions, and orders
- π Position Management - Monitor open positions with PnL tracking
- π Order Management - View and cancel open orders
- π° Deposit & Withdraw - Manage funds (requires backend integration)
- π¨ Modern UI - Beautiful, responsive design with Tailwind CSS
- Node.js 18+ and npm/yarn
- MetaMask browser extension installed
- Backend server running (see main README.md)
- Navigate to the frontend directory:
cd frontend- Install dependencies:
npm install
# or
yarn install- Create environment file (optional):
cp .env.example .envEdit .env if you need to change the API URL:
VITE_API_URL=http://localhost:5001npm run dev
# or
yarn devThe frontend will start on http://localhost:3000
npm run build
# or
yarn buildThe built files will be in the dist directory.
frontend/
βββ src/
β βββ components/ # React components
β β βββ WalletConnect.jsx
β β βββ Orders.jsx
β β βββ Positions.jsx
β β βββ Balance.jsx
β β βββ Deposit.jsx
β β βββ Withdraw.jsx
β βββ hooks/ # Custom React hooks
β β βββ useWallet.js
β βββ services/ # API services
β β βββ api.js
β βββ utils/ # Utility functions
β β βββ wallet.js
β βββ App.jsx # Main app component
β βββ main.jsx # Entry point
β βββ index.css # Global styles
βββ index.html
βββ package.json
βββ vite.config.js
βββ tailwind.config.js
- Make sure MetaMask is installed in your browser
- Click "Connect MetaMask" button
- Approve the connection request in MetaMask
- Your wallet address will be displayed
- Navigate to the "Balance" tab (default)
- View your account value, collateral, margin used, and PnL
- Data refreshes automatically every 10 seconds
- Navigate to the "Orders" tab
- View all open orders with details (coin, side, size, price)
- Cancel individual orders or cancel all orders at once
- Orders refresh automatically every 10 seconds
- Navigate to the "Positions" tab
- See all open positions with:
- Entry price
- Position size
- Leverage
- Unrealized PnL
- Liquidation price
- Positions refresh automatically every 10 seconds
- Navigate to the "Deposit" tab
- Select token (USDC/USDT)
- Enter amount
- Click "Deposit"
- Sign the transaction in MetaMask
Note: Deposit functionality requires backend integration with Hyperliquid smart contracts. The current implementation is a placeholder UI.
- Navigate to the "Withdraw" tab
- Select token (USDC/USDT)
- Enter amount
- Click "Withdraw"
- Sign the transaction in MetaMask
Note: Withdrawal functionality requires backend integration with Hyperliquid smart contracts. The current implementation is a placeholder UI.
- React 18 - UI framework
- Vite - Build tool and dev server
- React Router - Client-side routing
- Ethers.js - Ethereum library for MetaMask integration
- Axios - HTTP client for API calls
- Tailwind CSS - Utility-first CSS framework
- Lucide React - Icon library
The frontend connects to the backend API at http://localhost:5001 by default. The API endpoints used are:
GET /health- Health checkGET /account/info- Account informationGET /account/balance- Account balanceGET /account/positions- Open positionsGET /orders/open- Open ordersPOST /orders/place- Place orderPOST /orders/cancel- Cancel orderPOST /orders/cancel-all- Cancel all ordersPOST /account/deposit- Initiate depositPOST /account/withdraw- Initiate withdrawal
The app uses MetaMask for wallet connection and transaction signing:
- Wallet Connection: Uses
ethers.BrowserProviderto connect to MetaMask - Account Management: Listens for account and chain changes
- Transaction Signing: Ready for deposit/withdraw transactions (requires contract integration)
- Create components in
src/components/ - Add API calls in
src/services/api.js - Update routing in
src/App.jsx - Add styles using Tailwind CSS classes
The app uses Tailwind CSS. Customize colors and theme in tailwind.config.js.
- Ensure MetaMask extension is installed
- Refresh the page
- Check browser console for errors
- Verify backend server is running on port 5001
- Check CORS settings in backend
- Verify API URL in
.envfile
- Ensure sufficient gas fees
- Check network connection
- Verify account has sufficient balance
- Never commit
.envfiles with sensitive data - Always verify transaction details before signing
- Use testnet for testing
- Keep MetaMask secure with strong password
MIT
For issues related to:
- Frontend: Check this repository
- Backend: See main README.md
- Hyperliquid: Check Hyperliquid Documentation