Skip to main content

Component Architecture

All components are client-side rendered (using "use client" directive) due to Web3 integration requirements. Components follow a consistent pattern of hooks, conditional rendering, and event handling.

Core Components

WalletConnect Component

Location: src/components/WalletConnect.tsx:1 Handles wallet connection, disconnection, and network switching with multi-connector support.

Features

  • Multi-wallet support (Injected, WalletConnect)
  • Automatic network switching to Sepolia
  • Real-time balance display
  • Modal connector selection
  • SSR-safe hydration

Usage Example

Key Implementation Details

Wagmi Hooks Used:
Auto Network Switching (src/components/WalletConnect.tsx:31):
Balance Display (src/components/WalletConnect.tsx:40):
Portal-based Modal (src/components/WalletConnect.tsx:157):

VaultDashboard Component

Location: src/components/VaultDashboard.tsx:1 Main dashboard displaying vault statistics, user portfolio, and strategy allocations.

Features

  • Real-time vault metrics (TVL, APY, user assets)
  • Active strategy monitoring
  • Quick deposit/withdraw actions
  • Live event listening for updates
  • Test token minting (Sepolia)

Contract Reads

Total Vault Assets (src/components/VaultDashboard.tsx:59):
Total Managed Assets:
User Shares and Assets:
User Growth Percentage:
Portfolio State (src/components/VaultDashboard.tsx:105):

Real-Time Event Listening (src/components/VaultDashboard.tsx:123)

Test Token Minting (src/components/VaultDashboard.tsx:167)


DepositModal Component

Location: src/components/DepositModal.tsx:1 Modal for depositing LINK tokens into the vault with automatic approval handling.

Features

  • Balance checking and validation
  • Automatic token approval
  • Sequential approve + deposit workflow
  • Transaction state management

Props

Unified Deposit Workflow (src/components/DepositModal.tsx:82)

Auto-Deposit After Approval (src/components/DepositModal.tsx:69):

AgentChat Component

Location: src/components/AgentChat.tsx:1 Interactive AI assistant for vault operations with transaction signing capabilities.

Features

  • Natural language interaction
  • Session-based conversation memory
  • Unsigned transaction handling
  • Auto-scrolling message history

Message Interface

Hooks Used (src/components/AgentChat.tsx:14)

Message Sending (src/components/AgentChat.tsx:71)

Transaction Signing (src/components/AgentChat.tsx:123)


StrategyCard Component

Location: src/components/StrategyCard.tsx:1 Displays individual strategy allocation with target vs. actual comparison.

Props

Deviation Calculation (src/components/StrategyCard.tsx:16)

Visual Indicator


DepositorsList Component

Location: src/components/DepositorsList.tsx:1 Displays active vault share holders by fetching Transfer events and current balances.

Holder Interface

Event-Based Discovery (src/components/DepositorsList.tsx:26)


Common Patterns

SSR Hydration Safety

Prevent hydration mismatches by mounting check:

Contract Address Validation

BigInt Formatting

Transaction State Management


Component Testing

Testing with Wagmi

Next Steps

Frontend Overview

Return to architecture overview

Web3 Integration

Learn Wagmi and Viem patterns