Real-time monitoring and custom alerts for dYdX v4 traders. Track positions, set up flexible alert rules, and receive notifications across multiple channels.
- Real-time Position Monitoring: Track multiple subaccounts with live updates from dYdX v4 Indexer
- Flexible Alert Rules: Create custom alerts based on margin ratio, equity, free collateral, liquidation distance, and individual positions
- Multi-Channel Notifications: Telegram, Discord, Slack, Email, PagerDuty, and Custom Webhooks
- Comprehensive Dashboard: Monitor all your positions, view alert history, and manage notification channels
- Advanced Risk Metrics: Real-time calculations of margin requirements, liquidation prices, and unrealized PnL
- Backend: FastAPI (Python 3.9+), SQLAlchemy, AsyncIO
- Frontend: Next.js 14 (TypeScript), TailwindCSS, Radix UI
- Database: SQLite (dev) / PostgreSQL (prod)
- Authentication: Supabase Auth
- Real-time: WebSocket for position updates
- Python 3.9+
- Node.js 18+
- Supabase account (for authentication)
cd backend
python3 -m venv venv
source venv/bin/activate # Windows: venv\Scripts\activate
pip install -r requirements.txt
cp .env.example .env
# Edit .env with your configuration
python -m app.main
Backend runs on http://localhost:8021
cd frontend
npm install
cp .env.example .env.local
# Edit .env.local with your configuration
npm run dev
Frontend runs on http://localhost:8022
# Database
DATABASE_URL=sqlite:///./app.db
# dYdX Indexer
DYDX_INDEXER_REST_URL=https://indexer.dydx.trade/v4
DYDX_INDEXER_WS_URL=wss://indexer.dydx.trade/v4/ws
# Authentication
SUPABASE_URL=your_supabase_url
SUPABASE_ANON_KEY=your_supabase_anon_key
SUPABASE_SERVICE_ROLE_KEY=your_supabase_service_role_key
SECRET_KEY=your_secret_key_here
# Monitoring
ENABLE_MONITOR=true
# CORS
CORS_ORIGINS=["http://localhost:8022","https://yourdomain.com"]
NEXT_PUBLIC_API_URL=http://localhost:8021
NEXT_PUBLIC_WS_URL=ws://localhost:8021
NEXT_PUBLIC_SUPABASE_URL=your_supabase_url
NEXT_PUBLIC_SUPABASE_ANON_KEY=your_supabase_anon_key
NEXT_PUBLIC_APP_URL=http://localhost:8022
- Visit
http://localhost:8022
and register an account - Add your dYdX subaccounts to monitor
- Configure notification channels (Telegram, Discord, etc.)
- Create custom alert rules with flexible conditions (margin ratio, equity, positions, etc.)
- Receive real-time alerts when conditions are met
Key endpoints:
POST /api/auth/register
- Register new userPOST /api/auth/login
- Login userGET /api/subaccounts
- List monitored subaccountsPOST /api/subaccounts
- Add subaccount to monitorGET /api/subaccounts/{id}/status
- Get real-time metricsGET /api/channels
- List notification channelsGET /api/alert-rules
- List alert rulesPOST /api/alert-rules
- Create custom alert ruleGET /api/markets
- Get market data with oracle pricesWS /ws
- WebSocket for real-time position updates
Full API docs: http://localhost:8021/docs
(FastAPI auto-generated)
# Create .env.docker with your configuration
docker compose up -d
Services will be available at:
- Backend:
http://localhost:8021
- Frontend:
http://localhost:8022
Backend (Railway, Render, AWS EC2):
uvicorn app.main:app --host 0.0.0.0 --port 8000
Frontend (Netlify, Vercel):
npm run build
Update environment variables in your deployment platform.
Backend:
cd backend
pytest
Frontend:
cd frontend
npm run lint
Python (Black):
cd backend
black .
TypeScript (Prettier):
cd frontend
npm run format
dydx/
├── backend/
│ ├── app/
│ │ ├── api/ # REST & WebSocket endpoints
│ │ ├── models/ # SQLAlchemy models
│ │ ├── services/ # Business logic (monitor, alerts, notifications)
│ │ └── core/ # Config, database, security
│ └── tests/
├── frontend/
│ ├── app/ # Next.js pages
│ ├── components/ # React components
│ └── lib/ # API client, utilities
└── README.md
This project is licensed under the Business Source License 1.1 (BSL 1.1).
- Free for non-commercial use: You can use, modify, and self-host this software for personal projects, development, and internal use
- Commercial use requires a license: You cannot offer this software as a SaaS product, bundle it in a commercial offering, or use it as part of consulting services without a separate commercial license
- Becomes open source in 4 years: On October 10, 2029, this software automatically converts to the Apache License 2.0
See the LICENSE file for full details.
Mert Köklü - @devmertt