Skip to main content
Glama

get_impermanent_loss

Calculate impermanent loss for a liquidity position on the Casper Network DEX. Provide account public key and pair contract to assess potential losses from price changes.

Instructions

Calculate impermanent loss for a liquidity position

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
account_public_keyYesAccount public key (hex)
pairYesPair contract package hash

Implementation Reference

  • The MCP tool handler for 'get_impermanent_loss' in the account tools registration.
    async ({ account_public_key, pair }) => {
      const il = await client.getImpermanentLoss(account_public_key, pair);
      return { content: [{ type: 'text' as const, text: JSON.stringify(il, null, 2) }] };
    },
  • Registration of the 'get_impermanent_loss' tool in the MCP server.
    server.tool(
      'get_impermanent_loss',
      'Calculate impermanent loss for a liquidity position',
      {
        account_public_key: z.string().describe('Account public key (hex)'),
        pair: z.string().describe('Pair contract package hash'),
      },
      async ({ account_public_key, pair }) => {
        const il = await client.getImpermanentLoss(account_public_key, pair);
        return { content: [{ type: 'text' as const, text: JSON.stringify(il, null, 2) }] };
      },
    );
  • SDK client method that calls the liquidity API to fetch impermanent loss data.
    async getImpermanentLoss(publicKey: string, pairHash: string): Promise<ImpermanentLoss> {
      const raw = await this.liquidityApi.getImpermanentLoss(publicKey, pairHash);
      return {
        pairContractPackageHash: raw.pair_contract_package_hash,
        value: raw.value,
        timestamp: raw.timestamp,
      };
    }
  • API method in LiquidityApi that performs the HTTP request to fetch impermanent loss data.
    async getImpermanentLoss(accountIdentifier: string, pairHash: string): Promise<ImpermanentLossApiResponse> {
      const response = await this.http.get<ApiResponse<ImpermanentLossApiResponse>>(
        `/accounts/${accountIdentifier}/liquidity-position-impermanent-loss`,
        { pair_contract_package_hash: pairHash }
      );
      return response.data;
    }
Behavior2/5

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

No annotations provided, so description carries full burden of behavioral disclosure. Fails to state this is a read-only calculation (though implied by 'get_' prefix), does not describe calculation methodology (current price ratio vs. entry price), return value format (percentage, absolute value, ratio), or performance characteristics. Critical gaps for a financial calculation tool.

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?

Single sentence with no redundancy. Efficiently states core purpose. However, extreme brevity results in underspecification for a financial calculation tool—conciseness here reflects minimalism rather than optimal information density.

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?

Inadequate for tool complexity. No output schema exists, yet description doesn't hint at return structure. For a DeFi financial calculation involving impermanent loss, fails to explain what the calculation represents (divergence loss vs. holding), units, or interpretation guidance. Relies entirely on input schema and domain knowledge.

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 coverage is 100% (both account_public_key and pair are documented), establishing baseline 3. Description adds no parameter context (does not explain that account_public_key + pair identify the specific position, nor clarifies 'pair contract package hash' format requirements). But schema descriptions suffice for basic understanding.

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?

States specific verb (calculate) and resource (impermanent loss for a liquidity position). Clear enough to distinguish from sibling tools like get_liquidity_positions (which retrieves position data) and build_add_liquidity (which creates positions). However, lacks explicit scope clarification that this computes a specific financial metric rather than retrieving stored data.

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?

No guidance on when to use this tool versus alternatives. Does not mention prerequisites (e.g., that a liquidity position must exist for the account/pair combination) or when to use get_liquidity_positions instead. No mention of typical workflow (e.g., call get_liquidity_positions first to verify position exists).

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/make-software/cspr-trade-mcp'

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