# 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-13).

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

## Facts

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

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-284cd51a -d '<json body>'
```

Example prompt: The price of ETH doubled since I entered my 50/50 ETH/USDC pool — can you calculate my impermanent loss percentage and tell me whether I would have been better off just holding, assuming I earned 0.5% in fees?

## When to prefer this

Choose this endpoint when you need a fast, on-demand computation of impermanent loss for a standard 50/50 constant-product AMM pool (Uniswap v2 style). It is ideal for DeFi agents evaluating LP profitability, post-exit analysis, or pre-entry risk modeling. Prefer this over building the IL formula manually when you also want the hold-vs-LP comparison and optional fee netting in a single call.

## Known failure modes

- Invalid or zero price ratio returns a validation error
- Negative fees or nonsensical inputs rejected with 4xx error
- Price ratio of 1 (no price change) returns 0% IL as expected edge case
- Missing required price ratio field causes a 400 Bad Request
- Service downtime returns 5xx 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 as a percentage, the comparative value of a hold-only strategy versus the LP position, and the net LP outcome after any optional fees earned are factored in — showing whether the LP position outperformed or underperformed simply holding the assets.

## 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-284cd51a/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)
