import React, { useEffect, useMemo, useState } from 'react'; import { fetchMarketplacePresets } from '../lib/marketplaceApi'; import { Activity, ArrowUpRight, CheckCircle, Cpu, Fingerprint, Info, LineChart, Scale, Shield, TrendingUp, Users, Zap, } from 'lucide-react'; import type { StrategyPreset } from '../lib/PresetRegistry'; import { STRATEGY_PRESETS } from '../lib/PresetRegistry'; import { Button } from './ui/button'; import { Card, CardContent, CardDescription, CardHeader, CardTitle } from './ui/card'; import { PageHeader } from './ui/page-header'; interface PresetMarketplaceProps { onSelect: (preset: StrategyPreset) => void; onClose?: () => void; } const themeByRisk: Record = { safe: { tone: 'safe', label: 'Low Volatility' }, balanced: { tone: 'balanced', label: 'Balanced' }, aggressive: { tone: 'aggressive', label: 'High Conviction' }, }; function metricForPreset(preset: StrategyPreset) { if (preset.riskStyleId === 'aggressive') { return { performance: '+14.2%', volatility: 'High', icon: Zap, accent: 'var(--destructive)' }; } if (preset.riskStyleId === 'safe') { return { performance: '+4.8%', volatility: 'Low', icon: Shield, accent: 'var(--primary)' }; } return { performance: '+8.5%', volatility: 'Medium', icon: Scale, accent: 'var(--ring)' }; } const StrategyMarketplaceCard: React.FC<{ preset: StrategyPreset; onSelect: (preset: StrategyPreset) => void; index: number; }> = ({ preset, onSelect, index }) => { const theme = themeByRisk[preset.riskStyleId] || themeByRisk.balanced; const metric = metricForPreset(preset); const RiskIcon = metric.icon; return (
Strategy Profile
{preset.riskStyleId} strategy
V{index + 1}.4
{preset.name}
{theme.label} • {metric.performance}
{preset.description} Optimized for automated execution without changing your core risk budget.
{[ { label: 'Growth', value: metric.performance, icon: }, { label: 'Latency', value: 'Low', icon: }, { label: 'Liquidity', value: 'Prime', icon: }, { label: 'Volatility', value: metric.volatility, icon: }, ].map((spec) => (
{spec.icon} {spec.label}
{spec.value}
))}
Logical invariant verified
Risk-isolated execution
); }; export const PresetMarketplace: React.FC = ({ onSelect, onClose }) => { const [customPresets, setCustomPresets] = useState([]); useEffect(() => { const fetchCustomPresets = async () => { try { const data = await fetchMarketplacePresets(); const mappedData = data.map((d: any) => ({ id: d.id, name: d.name, description: d.description, riskStyleId: d.risk_style_id, recommendedAssets: d.recommended_assets, typicalTradesPerDay: d.typical_trades_per_day, performanceTag: d.performance_tag, isPopular: d.is_popular, strategy_config: d.strategy_config, })); setCustomPresets(mappedData as StrategyPreset[]); } catch (e) { console.error('Error fetching marketplace presets:', e); } }; void fetchCustomPresets(); }, []); const allPresets = useMemo(() => [...STRATEGY_PRESETS, ...customPresets], [customPresets]); return (
{allPresets.length} presets
{onClose ? ( ) : null}
{allPresets.map((preset, idx) => ( ))}
Analyzing DNA

Verification queue is active for new marketplace strategies.

); };