Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion client/src/components/orderbook/Orderbook.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface OrderbookProps {
onPriceClick?: (price: number) => void;
}

export function Orderbook({ orderbook, asset, isLoading, compact = false, onPriceClick }: OrderbookProps) {
export function Orderbook({ orderbook, asset, isLoading: _isLoading, compact = false, onPriceClick }: OrderbookProps) {
// Show loading or empty state
if (!orderbook || (orderbook.bids.length === 0 && orderbook.asks.length === 0)) {
return (
Expand Down
1 change: 0 additions & 1 deletion client/src/components/trading/OpenOrders.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { useState, useEffect } from 'react';
import { api } from '../../lib/api';
import { formatUSD } from '../../lib/utils';
import { cn } from '../../lib/utils';
import type { LimitOrder } from '../../types/trading';
import { Spinner } from '../ui/Spinner';
Expand Down
1 change: 1 addition & 0 deletions client/src/components/trading/OrderForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,7 @@ export function OrderForm({
if (orderType === 'limit' && !limitPrice && currentPrice > 0) {
setLimitPrice(currentPrice.toFixed(2));
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [currentPrice, orderType]);

useEffect(() => {
Expand Down
5 changes: 4 additions & 1 deletion client/src/context/AuthContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@ export function AuthProvider({ children }: { children: ReactNode }) {

useEffect(() => {
store.initialize();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

return (
Expand All @@ -29,11 +30,13 @@ export function AuthProvider({ children }: { children: ReactNode }) {
);
}

// eslint-disable-next-line react-refresh/only-export-components
export function useAuth() {
const context = useContext(AuthContext);
const store = useAuthStore();
if (!context) {
// Return store directly if not wrapped in provider
return useAuthStore();
return store;
}
return context;
}
2 changes: 2 additions & 0 deletions client/src/context/MarketContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@ export function MarketProvider({ children }: { children: ReactNode }) {
return () => {
store.unsubscribeFromAsset(store.selectedAsset);
};
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isConnected, store.selectedAsset]);

return (
Expand All @@ -53,6 +54,7 @@ export function MarketProvider({ children }: { children: ReactNode }) {
);
}

// eslint-disable-next-line react-refresh/only-export-components
export function useMarket() {
const context = useContext(MarketContext);
if (!context) {
Expand Down
1 change: 1 addition & 0 deletions client/src/context/ToastContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ export function ToastProvider({ children }: { children: ReactNode }) {
);
}

// eslint-disable-next-line react-refresh/only-export-components
export function useToast() {
const context = useContext(ToastContext);
if (!context) {
Expand Down
3 changes: 3 additions & 0 deletions client/src/context/TradingContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -30,12 +30,14 @@ export function TradingProvider({ children }: { children: ReactNode }) {
if (isConnected) {
positionsStore.subscribeToPositions();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isConnected]);

useEffect(() => {
accountStore.fetchAccount();
accountStore.fetchStats();
positionsStore.fetchPositions();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const refreshData = async () => {
Expand Down Expand Up @@ -67,6 +69,7 @@ export function TradingProvider({ children }: { children: ReactNode }) {
);
}

// eslint-disable-next-line react-refresh/only-export-components
export function useTrading() {
const context = useContext(TradingContext);
if (!context) {
Expand Down
3 changes: 1 addition & 2 deletions client/src/context/WebSocketContext.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,6 @@ export function WebSocketProvider({ children }: { children: ReactNode }) {
connect();

const handleConnect = () => setIsConnected(true);
const handleDisconnect = () => setIsConnected(false);

wsClient.on('connected', handleConnect);

return () => {
Expand All @@ -53,6 +51,7 @@ export function WebSocketProvider({ children }: { children: ReactNode }) {
);
}

// eslint-disable-next-line react-refresh/only-export-components
export function useWS() {
const context = useContext(WebSocketContext);
if (!context) {
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useAccount.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { create } from 'zustand';
import { api } from '../lib/api';
import type { Account } from '../types/trading';
import type { UserStats } from '../types/user';
import { TRADING_CONSTANTS } from '../config/constants';


interface AccountState {
account: Account | null;
Expand Down
4 changes: 2 additions & 2 deletions client/src/hooks/useAuth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { persist } from 'zustand/middleware';
import { supabase } from '../lib/supabase';
import { api } from '../lib/api';
import { wsClient } from '../lib/websocket';
import type { User, Profile, AuthState } from '../types/user';
import type { AuthState } from '../types/user';

// Generate a fake email from username for Supabase auth
const usernameToEmail = (username: string) => `${username.toLowerCase()}@hypersim.local`;
Expand All @@ -18,7 +18,7 @@ interface AuthStore extends AuthState {

export const useAuthStore = create<AuthStore>()(
persist(
(set, get) => ({
(set, _get) => ({
user: null,
profile: null,
isAuthenticated: false,
Expand Down
2 changes: 1 addition & 1 deletion client/src/hooks/useWebSocket.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ interface UseWebSocketOptions {
}

export function useWebSocket(options: UseWebSocketOptions = {}) {
const { autoConnect = true, onMessage, onConnect, onDisconnect, onError } = options;
const { autoConnect = true, onMessage, onConnect, onError } = options;
const [isConnected, setIsConnected] = useState(wsClient.isConnected);
const handlersRef = useRef<Map<string, (message: WSMessage) => void>>(new Map());

Expand Down
1 change: 1 addition & 0 deletions client/src/pages/LeaderboardPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ export function LeaderboardPage() {

useEffect(() => {
fetchLeaderboard();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const totalPages = Math.ceil(total / pageSize);
Expand Down
1 change: 0 additions & 1 deletion client/src/pages/LoginPage.tsx
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
import { useState } from 'react';
import { Link, useNavigate } from 'react-router-dom';
import { useAuthStore } from '../hooks/useAuth';
import { LoginForm } from '../components/auth/LoginForm';
Expand Down
1 change: 1 addition & 0 deletions client/src/pages/ProfilePage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function ProfilePage() {
useEffect(() => {
fetchAccount();
fetchStats();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const handleReset = async () => {
Expand Down
6 changes: 5 additions & 1 deletion client/src/pages/TradingPage.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ export function TradingPage() {

useEffect(() => {
fetchAssets();
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

const positionsWithLivePnl: Position[] = positions.map((position) => {
Expand Down Expand Up @@ -83,10 +84,12 @@ export function TradingPage() {
subscribeToPositions();
}
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isConnected, selectedAsset, isAuthenticated]);

useEffect(() => {
fetchCandles(selectedAsset, selectedTimeframe);
// eslint-disable-next-line react-hooks/exhaustive-deps
}, []);

useEffect(() => {
Expand All @@ -95,6 +98,7 @@ export function TradingPage() {
fetchAccount();
fetchStats();
}
// eslint-disable-next-line react-hooks/exhaustive-deps
}, [isAuthenticated]);

const handlePlaceOrder = async (order: Parameters<typeof placeOrder>[0]) => {
Expand Down Expand Up @@ -168,7 +172,7 @@ export function TradingPage() {
setLimitPriceFromOrderbook(price);
}, []);

const filteredAssets = useMemo(() => getFilteredAssets(), [getFilteredAssets, searchQuery]);
const filteredAssets = useMemo(() => getFilteredAssets(), [getFilteredAssets]);
const openPositions = positions.filter(p => p.status === 'open');

// Trophy Icon - Gray to match unselected nav items
Expand Down
10 changes: 10 additions & 0 deletions client/vite.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,15 @@ export default defineConfig({
build: {
outDir: 'dist',
sourcemap: true,
rollupOptions: {
output: {
manualChunks: {
'react-vendor': ['react', 'react-dom', 'react-router-dom'],
'supabase': ['@supabase/supabase-js'],
'charts': ['lightweight-charts'],
'state': ['zustand'],
},
},
},
},
});
1 change: 0 additions & 1 deletion server/src/app.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import express from 'express';
import cors from 'cors';
import helmet from 'helmet';
import { config } from './config/index.js';
import { errorMiddleware } from './middleware/error.middleware.js';
import { rateLimitMiddleware } from './middleware/rateLimit.middleware.js';
import { authRoutes } from './routes/auth.routes.js';
Expand Down
2 changes: 1 addition & 1 deletion server/src/middleware/error.middleware.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ export function errorMiddleware(
error: Error,
req: Request,
res: Response,
next: NextFunction
_next: NextFunction
) {
logger.error(`${req.method} ${req.path}: ${error.message}`);

Expand Down
1 change: 0 additions & 1 deletion server/src/middleware/validation.middleware.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { Request, Response, NextFunction } from 'express';
import { z } from 'zod';
import { ValidationError } from '../lib/errors.js';

export function validateBody<T extends z.ZodSchema>(schema: T) {
return (req: Request, res: Response, next: NextFunction) => {
Expand Down
2 changes: 1 addition & 1 deletion server/src/routes/auth.routes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ authRoutes.post('/register', validateBody(registerSchema), async (req, res) => {
});

// Generate session
const { data: session, error: sessionError } = await supabase.auth.admin.generateLink({
await supabase.auth.admin.generateLink({
type: 'magiclink',
email,
});
Expand Down
2 changes: 1 addition & 1 deletion server/src/services/binance/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -285,7 +285,7 @@ export class BinanceKlineService {

// Close all connections
disconnect(): void {
for (const [streamName, ws] of this.connections) {
for (const [, ws] of this.connections) {
ws.close();
}
this.connections.clear();
Expand Down
1 change: 0 additions & 1 deletion server/src/services/trading/accountManager.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { v4 as uuidv4 } from 'uuid';
import { getSupabase } from '../../lib/supabase.js';
import { NotFoundError } from '../../lib/errors.js';
import { TRADING_CONSTANTS } from '../../config/constants.js';
import { PnlCalculator } from './pnlCalculator.js';
import type { Account } from '../../types/trading.js';
Expand Down
2 changes: 1 addition & 1 deletion server/src/websocket/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ export class WebSocketServer {
if (message.channel) {
if (!connection.subscriptions.has(message.channel)) {
// Check for wildcard subscriptions
const [type, asset] = message.channel.split(':');
const [type] = message.channel.split(':');
if (!connection.subscriptions.has(`${type}:*`)) {
continue;
}
Expand Down
Loading