# Impermanent Loss Calculator

> Impermanent Loss Calculator is a paid API for AI agents from api.24klabs.ai, paid per call via x402, $0.003/call, status unknown (last checked 2026-09-15).

Calculates impermanent loss percentage and hold-vs-LP value comparison for a 50/50 liquidity pool given the price ratio of the volatile asset, optionally netting fees earned.

## Facts

- Endpoint: POST https://api.24klabs.ai/api/v1/impermanent-loss-calculator
- Price: $0.003/call
- Payment: x402
- Status: unknown
- Last checked: 2026-09-15
- Activations on Zero: 0
- Tags: x402
- Canonical page: https://www.zero.xyz/c/impermanent-loss-calculator-69264c3c
- Structured record (JSON): https://api.zero.xyz/v1/capabilities/cap_EfIj0OfhggjI-krL8GQTb

Status and success rate cover calls made through Zero and Zero's own probes. Third-party monitors may report differently.

## How to call it through Zero

Zero handles the 402 payment challenge and records the run. With the Zero CLI installed (`npm i -g @zeroxyz/cli`):

```sh
zero fetch --capability impermanent-loss-calculator-69264c3c -d '<json body>'
```

Example prompt: Calculate the impermanent loss for a 50/50 liquidity pool where the token price has gone from $1.00 to $2.50 — and factor in $120 in fees I earned to show my true LP outcome.

## When to prefer this

Use this endpoint when you need a precise, fee-adjusted impermanent loss calculation for a standard 50/50 AMM liquidity pool. Prefer this over manual calculation or general DeFi analytics APIs when you specifically need the hold-vs-LP value comparison with optional fee netting in a single call. Best suited for DeFi portfolio trackers, LP decision-support agents, and yield optimization workflows.

## Known failure modes

- Invalid or missing price ratio (e.g. zero or negative ratio) returns validation error
- Fees provided as negative number may cause computation error
- Price ratio of exactly 1.0 returns 0% impermanent loss (valid edge case)
- Missing required price ratio field returns 400-level error

## How this service works

Impermanent loss % and hold-vs-LP value for a 50/50 pool from the price ratio (new/old) of the volatile asset; nets optional fees earned to show true LP outcome.

## Output

Returns the impermanent loss percentage, the current value of the LP position, the equivalent hold value (if tokens had been held instead of deposited), and optionally the net LP outcome after subtracting or adding fees earned — allowing a direct comparison of LP vs hold strategy.

## Request schema (JSON Schema)

```json
{
 "type": "object",
 "properties": {
  "fees_earned": {
   "type": "number"
  },
  "price_ratio": {
   "type": "number"
  },
  "initial_value": {
   "type": "number"
  }
 }
}
```

## Response schema (JSON Schema)

```json
{
 "type": "json",
 "example": {
  "lp_value": 1414.21,
  "hold_value": 1500,
  "impermanent_loss_pct": -5.72
 }
}
```

## More

- Live health (JSON, refreshed every minute): https://www.zero.xyz/c/impermanent-loss-calculator-69264c3c/health.json
- [Zero catalog index](https://www.zero.xyz/llms.txt)
- [Other services from api.24klabs.ai](https://www.zero.xyz/host/api.24klabs.ai/llms.txt)
