Impermanent Loss Calculator

Closed-form impermanent loss for a full-range constant-product position given entry and current prices, with the formula stated in the response.

POST /v1/xlayer/impermanent-loss $0.01 per call

Informational only. This endpoint produces analysis, not advice. Do not use it as the sole basis for a financial, security or engineering decision. The closed form applies to a full-range constant-product position. A concentrated Uniswap v3 position experiences larger loss within its range and converts entirely to one asset outside it, so this understates the loss for such positions.

Specification

Endpoint
POST /v1/xlayer/impermanent-loss
Price
$0.01 per call · tier standard_data
Payment
x402 on X Layer (chain 196) · settled in USDG or USDT0 · scheme exact
Data source
X Layer JSON-RPC and on-chain DEX factory/pair reads
Timeout
30 seconds
Max request
32 KB
Version
1.0.0

Calling it

The first call returns a 402 with the payment challenge. Retry with a signed authorisation in the X-PAYMENT header — see the payment guide for the exact shape.

curl -i -X POST "https://api.dana-edu.pp.ua/v1/xlayer/impermanent-loss" \
  -H "content-type: application/json" \
  -d '{ ... }'

Response

Real output, captured by running this endpoint at build time — not written by hand. Volatile fields such as timestamps are elided. Captured 2026-07-30.

{
  "entry_price": "2000",
  "current_price": "3000",
  "price_ratio": "1.5",
  "impermanent_loss_fraction": "-0.0202041028867287607210863701176434432136",
  "impermanent_loss_percent": "-2.020410288672876072108637012",
  "value_if_held_ratio": "1.25",
  "value_in_pool_ratio": "1.224744871391589049098642037352945695983",
  "loss_amount": "-252.5512860841095090135796265",
  "formula": "IL = 2*sqrt(r) / (1 + r) - 1, where r = current price / entry price",
  "properties": {
    "always_non_positive": true,
    "zero_when_price_unchanged": true,
    "symmetric_in_ratio": "a doubling and a halving produce the same loss, because r and 1/r give the same IL"
  },
  "excludes": "trading fees earned, which are what compensate an LP for this loss, and any incentive rewards",
  "informational_only": "Informational only. Derived from on-chain state at a point in time. Not investment advice and not a recommendation."
}

Every response is wrapped in the same envelope: data plus warnings, sources, confidence, informational_only and a measured processing_ms. See the envelope reference.

Related endpoints