Skip to main content
Glama

LP Divergence-Loss Gate

lp_risk
Read-onlyIdempotent

Forward-looking liquidity-provision risk. Given a realized price ratio (for impermanent loss) and/or a volatility + horizon (for expected divergence / LVR), returns the closed-form IL, the expected −σ²T/8 divergence, and — with a fee APR — the net forecast and breakeven volatility (the vol above which fees no longer cover the bleed). Self-checked: the IL closed form is verified at the token level against explicit constant-product amounts. Call before providing liquidity to see whether the fee yield can plausibly beat the divergence loss.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
feeAprPctNoannualized fee yield estimate
capitalUsdNoposition capital in USD — losses are also reported in USD
priceRatioNorealized P1/P0 for realized IL
volatilityNoper-period vol (decimal) for expected divergence
horizonPeriodsNoperiods (default 1)
periodsPerYearNodefault 365
concentrationFactorNoV3 amplifier ≥1 (default 1)

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
okNofalse when the engine rejected the input
modelNomodel assumptions used
proofNoVerifiability envelope: echoed inputs, engine codeHash, contentHash of this exact result, self-checks, EIP-712 signature (EAS-ready). Re-run the open engine on `inputs` to reproduce the result byte-for-byte.
checksNoGround-truth self-checks; the result is untrustworthy if any fails.
realizedILNoclosed-form impermanent loss at the realized price ratio
feeVsDivergenceNonet forecast and breakeven volatility vs the fee APR
expectedDivergenceNoexpected divergence loss / LVR over the horizon (−σ²T/8 law)
concentrationFactorNoV3 concentration amplifier applied

TDQS

A4.7/5.0
Behavior5/5

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

Beyond annotations (readOnly, idempotent), the description reveals computation behavior, self-verification ('Self-checked: the IL closed form is verified'), and output details. No contradiction with annotations.

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

Conciseness5/5

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

Every sentence contributes value: purpose, input/output list, verification note, usage recommendation. No wasted words; information is front-loaded.

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

Completeness5/5

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

For a tool with 7 parameters and an existing output schema, the description covers inputs, computation, verification, and usage. It is sufficiently complete for an agent to select and invoke correctly.

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

Parameters4/5

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

Schema coverage is 100%, but the description adds context linking parameters (e.g., 'capitalUsd' for USD loss reporting, 'priceRatio' for realized IL). It explains how parameters combine to produce outputs, enhancing schema details.

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

Purpose5/5

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

The description explicitly states the tool's purpose: 'Forward-looking liquidity-provision risk.' It details inputs (price ratio, volatility/horizon) and outputs (IL, divergence, net forecast, breakeven volatility), and distinguishes itself from sibling tools by focusing on pre-liquidity assessment.

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

Usage Guidelines4/5

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

The description provides clear guidance: 'Call before providing liquidity to see whether the fee yield can plausibly beat the divergence loss.' It implies appropriate context but does not explicitly state when not to use the tool.

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

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.

TDQS

A4.6/5.0
Disambiguation5/5

Each tool addresses a distinct risk domain (event volatility, execution verification, LP risk, options, perps, portfolio, attestation, sizing, treasury) with no overlap; descriptions are precise and differentiate clearly.

Naming Consistency5/5

All tool names follow a consistent snake_case pattern combining a domain prefix with a verb or metaphor (e.g., _risk, _gate, _verify), making them predictable and easy to parse.

Tool Count5/5

The 9 tools cover a broad range of DeFi risk computations without being excessive; each tool serves a clear, non-redundant purpose within the server's scope.

Completeness5/5

The tool set provides comprehensive coverage for a risk analysis server: event risk, execution quality, LP risk, options and perps greeks, portfolio stress, attestation, sizing, and treasury risk; no obvious gaps for the intended domain.

Resources