{"uid":"cap_1aV8qanVRhevArxHKMHZO","slug":"lifo-cost-basis-matching-for-crypto-asset-disposals-d313f130","name":"LIFO Cost-Basis Matching for Crypto/Asset Disposals","description":"LIFO cost-basis matching: newest lots consumed first, with realized gain per disposal in exact decimal math","url":"https://evm-canon-base.onrender.com/lots/lifo","method":"POST","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method","bodyType","body"],"properties":{"body":{"type":"object","required":["trades"],"properties":{"trades":{"type":"array","items":{"type":"object","required":["side","asset","amount","price","time"],"properties":{"fee":{"type":"string"},"side":{"enum":["buy","sell"],"type":"string"},"time":{"description":"unix seconds/millis or ISO-8601"},"asset":{"type":"string"},"price":{"type":"string","description":"unit price in the quote currency"},"amount":{"type":"string","description":"decimal string, never a float"}}}}}},"type":{"type":"string","const":"http"},"method":{"enum":["POST","PUT","PATCH"],"type":"string"},"bodyType":{"enum":["json","form-data","text"],"type":"string"}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object"}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.05","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.05/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.05","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_rthLZg4-XUx8K8yemOYwR","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.05","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Applies Last-In-First-Out (LIFO) cost-basis matching to a list of acquisition lots and disposal events, returning realized gain/loss per disposal calculated in exact decimal arithmetic.","exampleAgentPrompt":"Apply LIFO cost-basis matching to my trade history — I bought 1 ETH at $1800 on Jan 1, 2 ETH at $2200 on Mar 1, then sold 1.5 ETH on Apr 15 — tell me my realized gain or loss using newest lots first, in exact decimal math.","exampleUseCases":[{"title":"Crypto tax reporting with LIFO","prompt":"I sold 0.5 BTC last month and I want to know my realized capital gain using LIFO — my lots were: 0.3 BTC bought at $28,000 on Feb 10 and 0.4 BTC bought at $34,000 on Sep 5. Can you calculate my gain using the newest lot first?"},{"title":"DeFi portfolio P&L reconciliation","prompt":"I've been swapping ETH in and out of a DeFi pool all year. Here are all my acquisition lots and disposal events — can you run LIFO cost-basis matching so I know exactly how much I realized on each swap, to the exact cent?"},{"title":"Active trader end-of-year tax prep","prompt":"I'm doing year-end tax prep for my crypto trading account. I have a list of 20 buy lots and 15 sell events for SOL — can you apply LIFO lot matching and give me the realized gain or loss for each disposal so I can report them accurately?"}],"resultDescription":"Returns a list of disposal results where each disposal event is matched against the most recently acquired lots first (LIFO order). Each result includes the specific lots consumed, quantity used from each lot, the cost basis applied, the proceeds, and the realized gain or loss computed in exact decimal arithmetic. Any remaining unconsumed lots are also returned.","failureModes":["Insufficient lot quantity to cover a disposal — returns an error if disposals exceed total acquired quantity","Malformed input (missing required lot fields like timestamp, quantity, or cost) — returns a validation error","Lots with non-parseable decimal values — may return arithmetic errors","Empty lots array — returns no matches and zero realized gain","Disposals before any acquisitions chronologically — may yield unexpected results or errors"],"whenToPreferThis":"Choose this endpoint when you need LIFO (Last-In-First-Out) cost-basis accounting specifically, as required by certain tax jurisdictions or accounting policies. Prefer it over FIFO when the user explicitly requests LIFO, or when tax strategy favors using recently acquired (potentially higher-cost) lots to minimize near-term realized gains. Use instead of the average-cost endpoint when per-lot tracking is required, and instead of HIFO when the newest lots rather than highest-cost lots should be consumed first.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T12:56:10.474Z","isFirstParty":false}