'use client'; import { useState } from 'react'; import { QRCodeSVG } from 'qrcode.react'; import { PageHeader } from '@/components/layout/page-header'; import { useMarketMakerConfig, useInitializeMarketMaker, useUpdateMarketMakerConfig, useDepositCash, useWithdrawCash, useDepositShares, useWithdrawShares, useBlockchainWithdrawCash, useBlockchainWithdrawShares, useStartTaker, useStopTaker, useTakeOrder, useStartMaker, useStopMaker, useRefreshOrders, useCancelAllOrders, useDepth, useDepthEnabled, useSetDepthEnabled, } from '@/features/market-maker'; import { Card, CardContent, CardHeader, CardTitle, CardDescription } from '@/components/ui/card'; import { Table, TableBody, TableCell, TableHead, TableHeader, TableRow } from '@/components/ui/table'; import { Button } from '@/components/ui/button'; import { Input } from '@/components/ui/input'; import { Label } from '@/components/ui/label'; import { Skeleton } from '@/components/ui/skeleton'; import { Badge } from '@/components/ui/badge'; import { Tabs, TabsContent, TabsList, TabsTrigger } from '@/components/ui/tabs'; import { Switch } from '@/components/ui/switch'; import { Dialog, DialogContent, DialogDescription, DialogFooter, DialogHeader, DialogTitle, DialogTrigger, } from '@/components/ui/dialog'; import { Play, Pause, AlertCircle, CheckCircle2, RefreshCw, Wallet, TrendingUp, TrendingDown, BarChart3, Zap, PlusCircle, MinusCircle, Copy, Check, } from 'lucide-react'; export default function MarketMakerPage() { const { data: configData, isLoading: configLoading, refetch } = useMarketMakerConfig(); const { data: depthData, isLoading: depthLoading } = useDepth(10); const { data: depthEnabled, isLoading: depthEnabledLoading } = useDepthEnabled(); const runningStatus = configData?.runningStatus; const initializeMutation = useInitializeMarketMaker(); const depositCashMutation = useDepositCash(); const withdrawCashMutation = useWithdrawCash(); const depositSharesMutation = useDepositShares(); const withdrawSharesMutation = useWithdrawShares(); const blockchainWithdrawCashMutation = useBlockchainWithdrawCash(); const blockchainWithdrawSharesMutation = useBlockchainWithdrawShares(); const startTakerMutation = useStartTaker(); const stopTakerMutation = useStopTaker(); const takeOrderMutation = useTakeOrder(); const startMakerMutation = useStartMaker(); const stopMakerMutation = useStopMaker(); const refreshOrdersMutation = useRefreshOrders(); const cancelAllOrdersMutation = useCancelAllOrders(); const setDepthEnabledMutation = useSetDepthEnabled(); const updateConfigMutation = useUpdateMarketMakerConfig(); const [initAccountSeq, setInitAccountSeq] = useState('MM001'); const [walletAddressInput, setWalletAddressInput] = useState(''); const [depositCashAmount, setDepositCashAmount] = useState(''); const [withdrawCashAmount, setWithdrawCashAmount] = useState(''); const [depositSharesAmount, setDepositSharesAmount] = useState(''); const [withdrawSharesAmount, setWithdrawSharesAmount] = useState(''); const [copiedAddress, setCopiedAddress] = useState(false); // 区块链提现 const [blockchainWithdrawCashAddress, setBlockchainWithdrawCashAddress] = useState(''); const [blockchainWithdrawCashAmount, setBlockchainWithdrawCashAmount] = useState(''); const [blockchainWithdrawSharesAddress, setBlockchainWithdrawSharesAddress] = useState(''); const [blockchainWithdrawSharesAmount, setBlockchainWithdrawSharesAmount] = useState(''); const handleCopyAddress = async (address: string) => { await navigator.clipboard.writeText(address); setCopiedAddress(true); setTimeout(() => setCopiedAddress(false), 2000); }; const config = configData?.config; const formatNumber = (value: string | undefined, decimals: number = 2) => { if (!value) return '0'; const num = parseFloat(value); if (isNaN(num)) return '0'; return num.toLocaleString(undefined, { minimumFractionDigits: decimals, maximumFractionDigits: decimals }); }; return (
总余额
{formatNumber(config.cashBalance, 2)}
可用余额
{formatNumber(config.availableCash, 2)}
冻结中
{formatNumber(config.frozenCash, 2)}
总余额
{formatNumber(config.shareBalance, 2)}
可用余额
{formatNumber(config.availableShares, 2)}
冻结中
{formatNumber(config.frozenShares, 2)}
单次最大买入比例
{formatNumber(String(parseFloat(config.maxBuyRatio) * 100), 2)}%
最小间隔
{config.minIntervalMs}ms
最大间隔
{config.maxIntervalMs}ms
价格策略
{config.priceStrategy}
买单档位
{config.bidLevels || 5}
买单价差
{formatNumber(String(parseFloat(config.bidSpread || '0.01') * 100), 2)}%
每档买单量
{formatNumber(config.bidQuantityPerLevel || '1000', 0)}
卖单档位
{config.askLevels || 5}
卖单价差
{formatNumber(String(parseFloat(config.askSpread || '0.01') * 100), 2)}%
每档卖单量
{formatNumber(config.askQuantityPerLevel || '1000', 0)}
深度显示
{depthEnabled?.enabled ? '用户可以在App中查看买卖深度' : '深度功能已关闭,用户无法查看'}
暂无买单
)}暂无卖单
)}