Skip to main content
The Chat Agent is a user-friendly assistant that helps MetaVault users interact with the vault, check balances, deposit, withdraw, and access public information while maintaining strict privacy and security boundaries.

Overview

Source: packages/agents/defi-portfolio/src/agents/sub-agents/chat-agent/agent.ts:18-145

Security & Privacy Rules

The Chat Agent enforces strict security boundaries:
  • Can ONLY access data for the user who is asking (using their wallet address)
  • NEVER exposes confidential information:
    • Strategy internals (leverage ratios, debt positions)
    • Admin-only functions (rebalance, harvest, update parameters)
    • Other users’ balances or private data
    • Liquidation or risk calculations (admin-only)
  • May ONLY reply using public vault information:
    • Total vault assets
    • APY
    • Token prices
    • User’s own balance and shares
Source: agent.ts:28-39

Available Tools

User Account Tools

Gets the current user’s vault share balance and withdrawable LINK amount.Schema:
Implementation:
Source: tools.ts:17-46Returns: User’s vault shares and withdrawable LINK amount (raw and human-readable)
Prepares an unsigned LINK deposit transaction for the user to sign in their wallet.Schema:
Implementation:
Source: tools.ts:170-195Returns: Unsigned transaction object for user to sign
Withdraws shares from the vault for the user.Schema:
Implementation:
Source: tools.ts:201-224Returns: Unsigned transaction object for user to sign
Converts LINK amount to Vault Share Tokens (VST).Schema:
Implementation:
Source: tools.ts:270-286Returns: Equivalent VST shares for given LINK amount
Converts Vault Share Tokens (VST) to LINK.Schema:
Implementation:
Source: tools.ts:288-304Returns: Equivalent LINK amount for given VST shares

Public Information Tools

Gets public vault information including total managed assets and total supply.Implementation:
Source: tools.ts:83-107Returns: Total managed assets and total supply (public data)
Fetches real-time LINK price from CoinGecko API.Implementation:
Source: tools.ts:229-268Returns: Current LINK price in USD and 24h price change
Gets the current vault APY based on TVL growth.Implementation:
Source: tools.ts:309-317Note: Reuses APY calculation logic from Strategy Sentinel AgentReturns: Current vault APY percentage

Approval / Deposit Support Tools

Checks if user’s LINK token allowance is enough for a deposit.Schema:
Implementation:
Source: tools.ts:109-135Returns: Whether allowance is sufficient and amounts

Communication Style

The Chat Agent follows specific formatting rules:
  • No Markdown, HTML, or special symbols (asterisks, underscores, backticks)
  • Use clear line breaks, indentation, and emojis for structure
  • Round numbers to 2 decimal points when displaying (NOT for transactions)
  • Be friendly, simple, and helpful
  • Explain what the user needs to sign (Approval or Deposit)
Source: agent.ts:23-26

Transaction Logic

Deposit Flow

When a user asks to deposit: Step 1: Call check_allowance(wallet, amount) Step 2A: If allowance is insufficient:
  • Call approve_link(amount)
  • Respond telling user they must first sign the approval transaction
  • After user signs approval, call user_deposit(amount)
Step 2B: If allowance is already enough:
  • Call user_deposit(amount) directly
  • Prepare deposit transaction
Source: agent.ts:67-75

Withdraw Flow

When a user asks to withdraw:
  • Call user_withdraw(shares) directly
  • No approval needed for withdrawals
Source: agent.ts:77-78

JSON Response Format

When using tools for DEPOSIT, WITHDRAW, APPROVAL, or CHECK_ALLOWANCE, the agent MUST return only valid JSON:
Fields:
  • reply: Human-friendly message
  • unsignedTx: Transaction user must sign (or null)
  • needsApproval: true only when approval is required
  • step: One of “approval”, “deposit”, “withdrawal”, or “info”
Source: agent.ts:103-124

Restrictions

If user asks about admin operations, the agent responds:
“I can help with deposits, withdrawals, balances, and public data. Strategy management is restricted to vault administrators.”
Admin operations include:
  • rebalance
  • harvest
  • risk parameters
Source: agent.ts:84-90

Example Interactions

Deposit with Approval

Source: agent.ts:92-102

Check Balance

Withdraw

Responsibilities Summary

The Chat Agent must:
  1. User Assistance - Help users deposit, withdraw, or check vault information
  2. Address Verification - Always ask for wallet address when accessing personal data
  3. Approval Management - Determine whether user needs approval transaction before deposit
  4. Transaction Preparation - Produce unsigned transactions for the wallet to sign
  5. Privacy Protection - Never expose admin functions or internal vault strategy logic
Source: agent.ts:59-90