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.
Primitives in this category
Section titled “Primitives in this category”AnalyzePosition— Uniswap V2/V3 IL + fee decomposition.AnalyzeBalancerPosition— 2-asset Balancer weighted-pool sibling.AnalyzeStableswapPosition— 2-asset Stableswap sibling with at-peg short-circuit and unreachable-α handling.
All three follow the same primitive interface: stateless construction, computation at .apply(), typed dataclass return.
Protocol coverage
Section titled “Protocol coverage”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.
| Protocol | Coverage | Notes |
|---|---|---|
| Uniswap V2 | Full | AnalyzePosition, V2 path — IL + fee decomposition + diagnosis. |
| Uniswap V3 | Full | AnalyzePosition, V3 path with lwr_tick / upr_tick for concentrated positions. |
| Balancer | Full | AnalyzeBalancerPosition, 2-asset weighted pools; ships with fee_income = 0.0 (no per-LP fee attribution in upstream). |
| Stableswap | Full | AnalyzeStableswapPosition, 2-asset; supports unreachable-alpha and at-peg short-circuit regimes. |
MCP tool exposure
Section titled “MCP tool exposure”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.