{"uid":"cap_aUqGzc5PVtt5JHeenujjO","slug":"impermanent-loss-calculator-284cd51a","name":"Impermanent Loss Calculator","description":"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.","url":"https://api.24klabs.ai/api/impermanent-loss-calculator","method":"POST","headers":{},"bodySchema":{"type":"object","properties":{"fees_earned":{"type":"number"},"price_ratio":{"type":"number"},"initial_value":{"type":"number"}}},"responseSchema":{"type":"json","example":{"lp_value":1414.21,"hold_value":1500,"impermanent_loss_pct":-5.72}},"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.003","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.003/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.003","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_P2yHy3qQWxhmQXUK7xDYg","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.003","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"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.","exampleAgentPrompt":"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?","exampleUseCases":[{"title":"Post-exit LP position review","prompt":"I just withdrew from a 50/50 WBTC/USDC pool. The price of WBTC went from $30,000 when I entered to $45,000 now, and I earned about $200 in fees on a $10,000 initial position. How much impermanent loss did I suffer, and did the fees make up for it?"},{"title":"Pre-entry LP risk assessment","prompt":"I'm thinking about entering a 50/50 SOL/USDC pool. If SOL's price were to go up 2.5x or drop to 40% of its current value, what would my impermanent loss percentage be in each scenario? I want to understand the downside before I commit."},{"title":"AMM pool strategy comparison","prompt":"I'm comparing two strategies: holding my tokens versus LP-ing in a 50/50 pool. The volatile asset's price has changed from my entry by a ratio of 1.8. Can you compute the impermanent loss and show me the hold value versus LP value so I can decide which performed better?"}],"resultDescription":"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.","failureModes":["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"],"whenToPreferThis":"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.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T18:55:58.650Z","isFirstParty":false}