Skip to content
Open
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
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import { useStyles } from '../../../../../component-library/hooks';
import styleSheet from './PerpsMarketTradesList.styles';
import PerpsRowSkeleton from '../PerpsRowSkeleton';
import { getPerpsDisplaySymbol } from '../../utils/marketUtils';
import { usePerpsLiveFills } from '../../hooks/stream';
import { usePerpsMarketFills } from '../../hooks/usePerpsMarketFills';
import { transformFillsToTransactions } from '../../utils/transactionTransforms';
import { PERPS_CONSTANTS } from '../../constants/perpsConfig';

Expand All @@ -30,25 +30,20 @@ const PerpsMarketTradesList: React.FC<PerpsMarketTradesListProps> = ({
const { styles } = useStyles(styleSheet, {});
const navigation = useNavigation<NavigationProp<PerpsNavigationParamList>>();

// Fetch all order fills via WebSocket for live updates
const { fills: orderFills, isInitialLoading: isLoading } = usePerpsLiveFills({
throttleMs: 0, // Instant updates for real-time activity
});
// Fetch order fills via WebSocket + REST API for complete history
// WebSocket provides instant updates, REST provides complete historical data
const { fills: marketFills, isInitialLoading: isLoading } =
usePerpsMarketFills({
symbol,
throttleMs: 0, // Instant updates for real-time activity
});

// Filter by symbol, transform, and limit to 3
// Transform fills to transactions and limit to 3
// Note: marketFills is already filtered by symbol and sorted by the hook
const trades = useMemo(() => {
// Filter fills for this market
const marketFills = orderFills.filter((fill) => fill.symbol === symbol);

// Sort by timestamp descending (newest first)
marketFills.sort((a, b) => b.timestamp - a.timestamp);

// Transform to transactions
const transactions = transformFillsToTransactions(marketFills);

// Limit to 3
return transactions.slice(0, PERPS_CONSTANTS.RECENT_ACTIVITY_LIMIT);
}, [orderFills, symbol]);
}, [marketFills]);

const handleSeeAll = useCallback(() => {
// Navigate to Activity > Trades tab
Expand Down
1 change: 1 addition & 0 deletions app/components/UI/Perps/hooks/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,7 @@ export { default as usePerpsToasts } from './usePerpsToasts';

// Transaction data hooks
export { usePerpsOrderFills } from './usePerpsOrderFills';
export { usePerpsMarketFills } from './usePerpsMarketFills';
export { usePerpsOrders } from './usePerpsOrders';
export { usePerpsFunding } from './usePerpsFunding';
export { useWithdrawalRequests } from './useWithdrawalRequests';
Expand Down
Loading
Loading