@@ -13,66 +13,7 @@ interface VaultDashboardProps {
1313 usdcBalance ?: number ;
1414}
1515
16- const VaultDashboard : React . FC < VaultDashboardProps > = ( { walletAddress, usdcBalance = 0 } ) => {
17- const { formattedTvl, formattedApy, summary, error, isLoading } = useVault ( ) ;
18- const toast = useToast ( ) ;
19- const [ activeTab , setActiveTab ] = useState < "deposit" | "withdraw" > ( "deposit" ) ;
20- const [ amount , setAmount ] = useState ( "" ) ;
21- const [ isProcessing , setIsProcessing ] = useState ( false ) ;
22- const [ pendingBalanceChange , setPendingBalanceChange ] = useState ( 0 ) ;
2316
24- const yieldRate = formattedApy ;
25- const tvl = formattedTvl ;
26- const strategy = summary . strategy ;
27- const availableBalance = Math . max ( 0 , usdcBalance + pendingBalanceChange ) ;
28- const estimatedUsdcFee = ( ( ) => {
29- const feeMatch = summary . networkFeeEstimate . match ( / ( [ 0 - 9 ] * \. ? [ 0 - 9 ] + ) \s * U S D C / i) ;
30- return feeMatch ? Number ( feeMatch [ 1 ] ) : 0 ;
31- } ) ( ) ;
32- const maxDepositAmount = Math . max ( 0 , availableBalance - estimatedUsdcFee ) ;
33- const maxWithdrawAmount = availableBalance ;
34- const maxAllowableAmount = activeTab === "deposit" ? maxDepositAmount : maxWithdrawAmount ;
35-
36- const handleTransaction = ( ) => {
37- const value = Number ( amount ) ;
38- if ( ! walletAddress || ! amount || isNaN ( value ) ) {
39- toast . warning ( {
40- title : "Enter a valid amount" ,
41- description : "Choose a wallet and amount before submitting the transaction." ,
42- } ) ;
43- return ;
44- }
45- if ( value > maxAllowableAmount ) {
46- toast . warning ( {
47- title : "Amount exceeds maximum" ,
48- description :
49- activeTab === "deposit"
50- ? `You can deposit up to ${ maxDepositAmount . toFixed ( 2 ) } USDC based on your available balance and fees.`
51- : `You can withdraw up to ${ maxWithdrawAmount . toFixed ( 2 ) } USDC.` ,
52- } ) ;
53- return ;
54- }
55- setIsProcessing ( true ) ;
56-
57- // Simulate transaction delay
58- setTimeout ( ( ) => {
59- if ( activeTab === "deposit" ) {
60- setPendingBalanceChange ( ( prev ) => prev + value ) ;
61- }
62- if ( activeTab === "withdraw" ) {
63- setPendingBalanceChange ( ( prev ) => prev - value ) ;
64- }
65- setAmount ( "" ) ;
66- setIsProcessing ( false ) ;
67- toast . success ( {
68- title : activeTab === "deposit" ? "Deposit queued" : "Withdrawal queued" ,
69- description :
70- activeTab === "deposit"
71- ? `${ value . toFixed ( 2 ) } USDC has been added to your pending vault activity.`
72- : `${ value . toFixed ( 2 ) } USDC has been added to your pending withdrawal activity.` ,
73- } ) ;
74- } , 2000 ) ;
75- } ;
7617const VaultDashboard : React . FC < VaultDashboardProps > = ( {
7718 walletAddress,
7819 usdcBalance = 0 ,
@@ -107,8 +48,6 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
10748 return ;
10849 }
10950
110- < div className = "glass-panel panel-padding-mobile" style = { { padding : '32px' } } >
111- { error && < ApiStatusBanner error = { error } /> }
11251 if ( actionType === "withdraw" && value > availableBalance ) {
11352 toast . warning ( {
11453 title : "Insufficient balance" ,
@@ -138,9 +77,6 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
13877 return (
13978 < div className = "vault-dashboard gap-lg" >
14079 < div className = "vault-dashboard-stats" >
141- < div className = "glass-panel" style = { { padding : "32px" } } >
142- { error && < ApiStatusBanner error = { error } /> }
143-
14480 < div
14581 className = "vault-stats-header flex justify-between items-center"
14682 style = { { marginBottom : "24px" } }
@@ -176,9 +112,6 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
176112 </ div >
177113 </ div >
178114
179- { /* Right Column - User Interaction */ }
180- < div style = { { flex : '1 1 400px' } } >
181- < div className = "glass-panel panel-padding-mobile" style = { { padding : '32px' , position : 'relative' , overflow : 'hidden' } } >
182115 < div
183116 style = { {
184117 height : "1px" ,
@@ -279,7 +212,6 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
279212 < div style = { { marginTop : "8px" , color : "var(--text-secondary)" , fontSize : "0.78rem" } } >
280213 RPC: { hasCustomRpcConfig ? "Custom" : "Default" } - { networkConfig . rpcUrl }
281214 </ div >
282- </ div >
283215 </ div >
284216 </ div >
285217
@@ -308,44 +240,6 @@ const VaultDashboard: React.FC<VaultDashboardProps> = ({
308240 pointerEvents : "none" ,
309241 } }
310242 />
311-
312- < div className = "flex justify-between items-center" style = { { marginBottom : '16px' } } >
313- < div style = { { color : 'var(--text-secondary)' , fontSize : '0.9rem' } } >
314- { activeTab === 'deposit' ? 'Amount to deposit' : 'Amount to withdraw' }
315- </ div >
316- < div style = { { color : 'var(--text-secondary)' , fontSize : '0.85rem' } } >
317- Balance: < span style = { { color : 'var(--text-primary)' , fontWeight : 600 } } > { walletAddress ? availableBalance . toFixed ( 2 ) : '0.00' } </ span >
318- </ div >
319- </ div >
320-
321- < div className = "input-group" style = { { marginBottom : '24px' } } >
322- < div className = "input-wrapper" >
323- < span style = { { color : 'var(--text-secondary)' , paddingRight : '12px' , borderRight : '1px solid var(--border-glass)' , marginRight : '16px' } } > USDC</ span >
324- < input
325- className = "input-field"
326- type = "number"
327- placeholder = "0.00"
328- value = { amount }
329- onChange = { ( e ) => setAmount ( e . target . value ) }
330- />
331- < button
332- style = { {
333- color : 'var(--accent-cyan)' ,
334- fontSize : '0.8rem' ,
335- fontWeight : 600 ,
336- background : 'var(--accent-cyan-dim)' ,
337- padding : '4px 10px' ,
338- borderRadius : '6px'
339- } }
340- onClick = { ( ) =>
341- setAmount ( maxAllowableAmount . toFixed ( 2 ) )
342- }
343- disabled = { ! walletAddress || maxAllowableAmount <= 0 }
344- >
345- MAX
346- </ button >
347- </ div >
348- </ div >
349243 { ! walletAddress && (
350244 < div
351245 style = { {
0 commit comments