{"uid":"cap_U8jQ_XD6q-tLZMIHmsvay","slug":"evm-canon-base-fifo-cost-basis-lot-matching-5c415838","name":"EVM Canon Base – FIFO Cost-Basis Lot Matching","description":"FIFO cost-basis matching: oldest lots consumed first, with realized gain per disposal in exact decimal math","url":"https://evm-canon-base.onrender.com/lots/fifo","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_HlgjWlzut44yspZhZE7Au","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":"Matches trade lots using FIFO (first-in, first-out) order and computes realized gain per disposal using exact decimal arithmetic","exampleAgentPrompt":"I need to calculate my realized capital gains using FIFO lot matching — here are my acquisition lots and disposals for ETH trades; consume the oldest lots first and give me the exact gain on each disposal.","exampleUseCases":[{"title":"Crypto tax report preparation","prompt":"I have a list of all my ETH buys and sells this year — can you run FIFO lot matching on them and tell me the realized gain or loss on each sale so I can fill out my tax forms?"},{"title":"DeFi portfolio gain reconciliation","prompt":"I've been swapping tokens on-chain all quarter. Take these acquisition and disposal records for USDC and WBTC and calculate my realized gains using first-in first-out, showing exactly which lots were consumed for each trade."},{"title":"Accounting audit trail for token disposals","prompt":"Our fund needs an exact decimal audit trail of realized gains on these token disposals matched against the oldest cost-basis lots. Please run FIFO matching on the attached lot and trade data."}],"resultDescription":"Returns a list of disposal events, each showing which acquisition lots were consumed (oldest first), the quantity and cost basis consumed from each lot, the proceeds, and the exact decimal realized gain or loss. Also returns any remaining unconsumed lot balances after matching.","failureModes":["Insufficient lot quantity — disposals exceed total acquisition quantities, returning an error or partial match","Malformed decimal precision — mismatched decimal places between lots causing computation errors","Missing required fields — acquisition or disposal records lacking timestamps or quantities","Out-of-order timestamps — lots or disposals with ambiguous or identical timestamps producing non-deterministic FIFO ordering","Empty lot list — no acquisition records provided, returning zero matches"],"whenToPreferThis":"Choose this endpoint when you need strict FIFO (first-in, first-out) cost-basis matching with exact decimal arithmetic — the standard method required by many tax jurisdictions for cryptocurrency. Prefer this over HIFO (which minimizes gains by consuming highest-cost lots first) or average-cost basis when the user specifically needs FIFO compliance or when the tax authority mandates it. Use instead of the net-position endpoint when realized gain per disposal is needed, not just net balance.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-09-15T06:51:19.311Z","isFirstParty":false}