Skip to content

Position Analysis

Position Analysis primitives decompose a live LP position into its drivers — impermanent loss, fee income, and net PnL — so an LLM (or a human) can answer the question “why is this position making or losing money?”

Three primitives, one per protocol family — the sibling pattern keeps each focused on its protocol’s natural math (per-token lists for Stableswap, weight fields for Balancer) without forcing isinstance dispatch into a single primitive.

All three follow the same primitive interface: stateless construction, computation at .apply(), typed dataclass return.

Position decomposition is supported across all four AMM families via sibling primitives. The category exists because “is my LP gaining or losing money, and why?” is the highest-traffic agent question, and the answer needs to come back as a typed object the LLM can reason about.

ProtocolCoverageNotes
Uniswap V2FullAnalyzePosition, V2 path — IL + fee decomposition + diagnosis.
Uniswap V3FullAnalyzePosition, V3 path with lwr_tick / upr_tick for concentrated positions.
BalancerFullAnalyzeBalancerPosition, 2-asset weighted pools; ships with fee_income = 0.0 (no per-LP fee attribution in upstream).
StableswapFullAnalyzeStableswapPosition, 2-asset; supports unreachable-alpha and at-peg short-circuit regimes.

All three primitives are surfaced as MCP tools in the curated v2.0 set. Position analysis is the highest-traffic agent question, so all three protocol siblings are exposed directly rather than left to the LLM to compose.