{"uid":"cap_VwvEKDTeDni4Fn2DyUX0E","slug":"finmath-cost-basis-calculator-affc463c","name":"finmath Cost Basis Calculator","description":"Deterministic finance and crypto math for AI agents: TradFi (NPV, IRR, XIRR, Black-Scholes + Greeks, bonds, VaR, Sharpe) and DeFi (impermanent loss, perp liquidation, funding, Uniswap v3, health factor, cost basis). Exact, model-free arithmetic that LLMs get wrong — priced per call in USDC.","url":"https://finmath.qzqh5rrbkz.workers.dev/v1/cost_basis","method":"POST","headers":{},"bodySchema":{"type":"object","required":["lots","sell_qty"],"properties":{"lots":{"type":"array","description":"lots"},"method":{"type":"string","description":"method"},"sell_qty":{"type":"number","description":"sell_qty"}}},"responseSchema":{"type":"object","required":["result","meta"],"properties":{"meta":{"type":"object"},"result":{}}},"example":{"request":{"lots":[{"quantity":1,"cost_per_unit":1800},{"quantity":1,"cost_per_unit":2200}],"method":"FIFO","sell_qty":1.5},"response":{"meta":{"tool":"cost_basis","disclaimer":"Deterministic calculation utility. Not financial, investment, or trading advice.","deterministic":true},"result":{"method":"FIFO","avg_cost":null,"cost_basis":null,"consumed_lots":[{"qty":null},{"qty":null}],"remaining_lots":[]}}},"exampleRequest":{"lots":[{"quantity":1,"cost_per_unit":1800},{"quantity":1,"cost_per_unit":2200}],"method":"FIFO","sell_qty":1.5},"tags":["x402"],"displayCostAmount":"0.002","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"settled","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.002/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.002","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_cpEBvjsfgZ2GPQIADez-U","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.002","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes cost basis for cryptocurrency or asset lots using configurable accounting methods (FIFO, LIFO, HIFO, etc.) given purchase lots and a sale quantity","exampleAgentPrompt":"Calculate the FIFO cost basis for selling 1.5 ETH — I bought 1 ETH at $1,800 on Jan 5, then 1 ETH at $2,200 on Mar 10, and now I'm selling 1.5 ETH.","exampleUseCases":null,"resultDescription":"Returns the computed cost basis result including lot allocations used, total cost basis amount, and metadata about the calculation method applied.","failureModes":["Missing required 'lots' array — returns validation error","Missing required 'sell_qty' — returns validation error","sell_qty exceeds total available quantity in lots — returns error or partial fill","Invalid method string — may default to FIFO or return error","Malformed lot objects missing price or quantity fields — returns parsing error","Payment not provided or insufficient USDC — returns 402 Payment Required"],"whenToPreferThis":"Use this endpoint when you need deterministic, exact cost basis arithmetic for tax reporting or portfolio tracking — especially for crypto assets where LLMs are known to make arithmetic errors. Prefer this over manual calculation or LLM reasoning when precision matters for FIFO/LIFO/HIFO lot matching or when computing realized gains for tax purposes.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-13T18:49:52.294Z","isFirstParty":false}