Skip to main content
Glama
Pavilion-devs

Saros MCP Server

simulate_rebalance

Simulate liquidity pool rebalancing based on impermanent loss thresholds to optimize DeFi positions. Provides adjustment recommendations for Solana wallets.

Instructions

Simulate rebalancing LP positions based on impermanent loss threshold. Provides recommendations for position adjustments.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
walletYesSolana wallet address
thresholdYesIL threshold percentage (e.g., 5 for 5%)

Implementation Reference

  • The main handler function for the 'simulate_rebalance' tool. It validates inputs, retrieves LP positions, generates rebalance recommendations using the analytics service, and returns formatted simulation results.
    async function simulateRebalanceTool(args, poolService, analyticsService) {
      const { wallet, threshold } = args;
    
      if (!wallet || threshold === undefined) {
        throw new Error("Wallet address and threshold are required");
      }
    
      if (threshold < 0 || threshold > 100) {
        throw new Error("Threshold must be between 0 and 100");
      }
    
      try {
        // Get current positions
        const positions = await poolService.getLPPositions(wallet);
    
        if (positions.length === 0) {
          return {
            content: [
              {
                type: "text",
                text: `No LP positions found for wallet: ${wallet}. Cannot simulate rebalance.`,
              },
            ],
          };
        }
    
        // Generate recommendations
        const recommendations = analyticsService.generateRebalanceRecommendations(
          positions,
          threshold
        );
    
        // Format simulation results
        let resultText = `**Rebalance Simulation for ${wallet}**\n\n`;
        resultText += `IL Threshold: ${threshold}%\n`;
        resultText += `Positions Analyzed: ${positions.length}\n`;
        resultText += `Recommendations: ${recommendations.length}\n\n`;
    
        if (recommendations.length === 0) {
          resultText += `✅ All positions are within acceptable IL range (< ${threshold}%). No rebalancing needed.`;
        } else {
          resultText += `**Recommendations:**\n`;
          recommendations.forEach((rec, idx) => {
            resultText +=
              `\n${idx + 1}. Pool: ${rec.poolAddress}\n` +
              `   - Current IL: ${rec.currentIL.toFixed(2)}%\n` +
              `   - Severity: ${rec.severity}\n` +
              `   - Action: ${rec.recommendation}\n`;
          });
        }
    
        return {
          content: [
            {
              type: "text",
              text: resultText,
            },
          ],
        };
      } catch (error) {
        throw new Error(`Failed to simulate rebalance: ${error.message}`);
      }
    }
  • Input schema validation for the 'simulate_rebalance' tool, specifying wallet address and IL threshold parameters.
    inputSchema: {
      type: "object",
      properties: {
        wallet: {
          type: "string",
          description: "Solana wallet address",
        },
        threshold: {
          type: "number",
          description: "IL threshold percentage (e.g., 5 for 5%)",
          minimum: 0,
          maximum: 100,
        },
      },
      required: ["wallet", "threshold"],
    },
  • src/index.js:64-84 (registration)
    Tool registration in the listTools handler, including name, description, and input schema.
    {
      name: "simulate_rebalance",
      description:
        "Simulate rebalancing LP positions based on impermanent loss threshold. Provides recommendations for position adjustments.",
      inputSchema: {
        type: "object",
        properties: {
          wallet: {
            type: "string",
            description: "Solana wallet address",
          },
          threshold: {
            type: "number",
            description: "IL threshold percentage (e.g., 5 for 5%)",
            minimum: 0,
            maximum: 100,
          },
        },
        required: ["wallet", "threshold"],
      },
    },
  • src/index.js:159-160 (registration)
    Tool dispatch in the CallToolRequestSchema handler, routing 'simulate_rebalance' calls to the simulateRebalanceTool function.
    case "simulate_rebalance":
      return await simulateRebalanceTool(args, this.poolService, this.analyticsService);
  • src/index.js:17-17 (registration)
    Import of the simulateRebalanceTool from its implementation file.
    const { simulateRebalanceTool } = require("./tools/simulate-rebalance.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 mentions 'simulate' and 'provides recommendations,' which implies a read-only, non-destructive operation, but does not confirm this or detail other traits like rate limits, authentication needs, or what the recommendations entail (e.g., format, scope). This leaves significant gaps for a tool with potential financial implications.

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 with two sentences that directly state the purpose and outcome. It is front-loaded with the core action and avoids unnecessary details. However, it could be slightly more structured by explicitly separating simulation from recommendation aspects.

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

Completeness2/5

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

Given the complexity of financial simulation and lack of annotations or output schema, the description is incomplete. It does not explain what the recommendations include (e.g., specific adjustments, risk assessment), how results are returned, or any limitations. For a tool with no structured output and behavioral gaps, more context is needed.

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?

Schema description coverage is 100%, with clear descriptions for both parameters (wallet as Solana address, threshold as IL percentage with range). The description adds no additional meaning beyond the schema, such as explaining how the threshold influences the simulation or what the wallet address is used for. Baseline 3 is appropriate as the schema does the heavy lifting.

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: 'Simulate rebalancing LP positions based on impermanent loss threshold' with the specific action 'Provides recommendations for position adjustments.' It distinguishes from siblings like get_farm_positions (which likely retrieves data) and swap_quote (which provides quotes), but could be more explicit about how it differs from portfolio_analytics in terms of simulation vs. analysis.

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 does not mention when to prefer simulate_rebalance over portfolio_analytics for analysis or get_lp_positions for data retrieval, nor does it specify prerequisites or exclusions. Usage is implied by the purpose but not explicitly stated.

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