Skip to main content
Glama
Pavilion-devs

Saros MCP Server

portfolio_analytics

Analyze DeFi portfolio performance on Solana by providing total value, impermanent loss metrics, yield data, and position breakdowns for any wallet address.

Instructions

Get comprehensive portfolio analytics including total value, IL metrics, yield performance, and position breakdown.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYesSolana wallet address

Implementation Reference

  • The handler function that executes the portfolio_analytics tool. Fetches LP positions for the wallet, analyzes the portfolio using analyticsService, formats metrics like total value, average impermanent loss (IL), position details, and provides a risk assessment. Returns formatted text content in MCP response format.
    async function portfolioAnalyticsTool(args, poolService, analyticsService) {
      const { wallet } = args;
    
      if (!wallet) {
        throw new Error("Wallet address is required");
      }
    
      try {
        // Get all positions
        const positions = await poolService.getLPPositions(wallet);
    
        if (positions.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `No positions found for wallet: ${wallet}`,
              },
            ],
          };
        }
    
        // Analyze portfolio
        const analytics = await analyticsService.analyzePortfolio(positions);
    
        // Format analytics output
        let analyticsText = `**Portfolio Analytics for ${wallet}**\n\n`;
        analyticsText += `**Overview:**\n`;
        analyticsText += `- Total Positions: ${analytics.positionCount}\n`;
        analyticsText += `- Estimated Total Value: $${analytics.totalValue.toFixed(2)}\n`;
        analyticsText += `- Average IL: ${analytics.averageIL.toFixed(2)}%\n\n`;
    
        analyticsText += `**Position Breakdown:**\n`;
        analytics.positions.forEach((pos, idx) => {
          analyticsText +=
            `\n${idx + 1}. Pool: ${pos.poolAddress.slice(0, 8)}...\n` +
            `   - LP Balance: ${pos.lpBalance}\n` +
            `   - Estimated Value: $${pos.estimatedValue.toFixed(2)}\n` +
            `   - IL: ${pos.impermanentLoss.toFixed(2)}%\n`;
        });
    
        analyticsText += `\n**Risk Assessment:**\n`;
        const avgIL = Math.abs(analytics.averageIL);
        if (avgIL < 2) {
          analyticsText += `✅ Low Risk - Portfolio is performing well`;
        } else if (avgIL < 5) {
          analyticsText += `⚠️ Medium Risk - Monitor positions closely`;
        } else {
          analyticsText += `🔴 High Risk - Consider rebalancing`;
        }
    
        return {
          content: [
            {
              type: "text",
              text: analyticsText,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to get portfolio analytics: ${error.message}`);
      }
    }
  • Input schema for the portfolio_analytics tool, defining the required 'wallet' string parameter.
    inputSchema: {
      type: "object",
      properties: {
        wallet: {
          type: "string",
          description: "Solana wallet address",
        },
      },
      required: ["wallet"],
    },
  • src/index.js:85-99 (registration)
    Registration of the portfolio_analytics tool in the ListToolsRequestSchema handler, including name, description, and input schema.
    {
      name: "portfolio_analytics",
      description:
        "Get comprehensive portfolio analytics including total value, IL metrics, yield performance, and position breakdown.",
      inputSchema: {
        type: "object",
        properties: {
          wallet: {
            type: "string",
            description: "Solana wallet address",
          },
        },
        required: ["wallet"],
      },
    },
  • src/index.js:162-163 (registration)
    Tool dispatch/registration in the CallToolRequestSchema switch statement, invoking the portfolioAnalyticsTool handler with services.
    case "portfolio_analytics":
      return await portfolioAnalyticsTool(args, this.poolService, this.analyticsService);
  • src/index.js:18-18 (registration)
    Import of the portfolioAnalyticsTool from its implementation file.
    const { portfolioAnalyticsTool } = require("./tools/portfolio-analytics.js");
Behavior2/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

No annotations are provided, so the description carries the full burden of behavioral disclosure. It describes the tool as a read operation ('Get'), implying it's likely safe and non-destructive, but fails to mention critical aspects like whether it requires authentication, has rate limits, or what the return format looks like. This leaves significant gaps in understanding the tool's behavior.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

The description is concise and front-loaded, consisting of a single sentence that efficiently states the tool's purpose and key metrics. There is no wasted verbiage, making it easy to parse, though it could be slightly more structured by explicitly separating different aspects of the analytics.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness3/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

Given the tool's complexity (providing comprehensive analytics) and lack of annotations and output schema, the description is moderately complete. It outlines what metrics are included but does not detail the return format, error conditions, or dependencies. This is adequate for a basic understanding but leaves gaps that could hinder effective use by an agent.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters3/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

The input schema has 100% description coverage, with the 'wallet' parameter clearly documented as a 'Solana wallet address'. The description adds no additional meaning beyond this, as it does not explain how the wallet parameter influences the analytics or provide any extra context. Baseline score of 3 is appropriate since the schema adequately covers the parameter.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose4/5

Does the description clearly state what the tool does and how it differs from similar tools?

The description clearly states the tool's purpose with specific verbs ('Get comprehensive portfolio analytics') and resources ('portfolio'), listing key metrics like total value, IL metrics, yield performance, and position breakdown. However, it does not explicitly distinguish this tool from sibling tools like 'get_farm_positions' or 'get_lp_positions', which might also provide position-related data, leaving some ambiguity in differentiation.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines2/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

The description provides no guidance on when to use this tool versus alternatives. It lacks explicit context, exclusions, or references to sibling tools, such as how it differs from 'get_farm_positions' or 'simulate_rebalance', leaving the agent without clear usage instructions.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/Pavilion-devs/saros-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server