> Quick Answer: Selling 2 units from four lots bought at $20,000, $55,000, $40,000, and $65,000 per unit, at a $70,000 sale price, produces a $65,000 taxable gain under FIFO but only a $20,000 gain under HIFO, a $45,000 difference in taxable gain from the exact same transaction, depending only on which lots you treat as sold.
Overview
Every time you sell, swap, or convert cryptocurrency, the IRS treats it as a sale of property, and the taxable gain is proceeds minus cost basis. That is simple in theory. It gets complicated the moment you have bought the same asset more than once, at different prices, because "cost basis" then depends entirely on which specific units you are considered to have sold.
The IRS allows two broad approaches. First-In-First-Out (FIFO) treats your earliest purchases as the ones sold first; it is the IRS's default method when a taxpayer cannot substantiate a specific-identification election. Highest-In-First-Out (HIFO), a form of specific identification, instead treats your highest-cost-basis units as sold first, regardless of purchase date. Because taxable gain is always proceeds minus cost basis, and HIFO always selects the highest cost basis available, it produces the smallest possible taxable gain (or largest deductible loss) of any lot-ordering method, for any given sale.
This calculator lets you enter up to four purchase lots, each with its own quantity and cost basis per unit, plus one sale, and shows the realized gain side by side under both FIFO and HIFO. It also flags which method actually applies to your situation: HIFO is only usable if you have documented, contemporaneous records identifying the specific lot sold at or before the time of the transaction; without that documentation, FIFO applies by default regardless of which method would produce a smaller gain.
How This Is Calculated
- Order the lots according to the method. FIFO keeps lots in the purchase-chronological order you entered them (Lot 1 earliest, Lot 4 most recent). HIFO re-sorts the same lots by cost basis per unit, from highest to lowest, ignoring purchase date entirely.
- Consume lots in that order until the sale quantity is satisfied. The calculator walks down the ordered list, taking as many units as are available from each lot before moving to the next, until it has matched the full quantity sold (or run out of lots).
- Compute proceeds and cost basis for the matched quantity. Proceeds = quantity matched × sale price per unit. Total cost basis consumed = the sum of (units taken from each lot × that lot's cost basis per unit).
- Realized gain = proceeds − total cost basis consumed. This is computed identically for both FIFO and HIFO; only the lot ordering, and therefore which specific cost-basis figures get consumed, differs between the two.
- Determine which method actually applies. If you have adequate specific-identification records, per IRS Rev. Rul. 2019-24, the HIFO result is the one that governs your actual tax liability. If you do not, FIFO is the IRS default regardless of the underlying preference to minimize gain.
All of this logic lives in this platform's shared calculateCostBasisFIFO and calculateCostBasisHIFO engine primitives, not inside this page, consistent with how every calculator on this platform handles its underlying math.
Worked Example
Using the calculator's own defaults: four lots of 1 unit each, purchased at $20,000, $55,000, $40,000, and $65,000 per unit respectively (in that chronological order), with a sale of 2 units at $70,000 per unit.
FIFO (consumes the earliest lots first): - Consume Lot 1: 1 unit at $20,000 cost basis. - Still need 1 more unit; consume Lot 2: 1 unit at $55,000 cost basis. - Total cost basis consumed: $20,000 + $55,000 = $75,000. - Proceeds: 2 × $70,000 = $140,000. - FIFO realized gain: $140,000 − $75,000 = $65,000.
HIFO (consumes the highest-cost-basis lots first, regardless of date): - Sorted by cost basis, highest first: Lot 4 ($65,000), Lot 2 ($55,000), Lot 3 ($40,000), Lot 1 ($20,000). - Consume Lot 4: 1 unit at $65,000 cost basis. - Still need 1 more unit; consume Lot 2: 1 unit at $55,000 cost basis. - Total cost basis consumed: $65,000 + $55,000 = $120,000. - Proceeds: 2 × $70,000 = $140,000 (unchanged; the sale itself is identical). - HIFO realized gain: $140,000 − $120,000 = $20,000.
The difference: $45,000 less taxable gain under HIFO than under FIFO, from the exact same sale of the exact same two units, purely as a function of which lots are considered sold. With adequate specific-identification records, HIFO is the applicable method here and the $20,000 figure is what actually gets reported; without those records, FIFO's $65,000 applies instead.
Why the Method You Are Entitled to Use Depends on Your Records
This is the detail that trips up the most crypto holders: you cannot simply choose HIFO because it produces a smaller number. The IRS's specific-identification rules require you to be able to identify, at or before the time of the transaction, which specific units were being sold, not reconstruct that identification later at tax time when you already know which choice is more favorable. Practically, this means either using exchange or wallet software that supports designating a specific lot at the moment of sale, or maintaining your own contemporaneous records (purchase date, quantity, and price for every lot, tied to the specific units transferred in each sale).
Starting with the 2025 tax year, IRS Revenue Procedure 2024-28 adds another layer: cost basis must generally be tracked on a wallet-by-wallet or account-by-account basis rather than pooled universally across every wallet and exchange a taxpayer uses, which is a significant operational shift from how many holders tracked basis before. This calculator models the FIFO/HIFO mechanics for a single pool of lots and a single sale; it does not model the wallet-by-wallet allocation requirement itself.
What This Does Not Account For
- The IRC §1091 wash sale rule does not currently apply to cryptocurrency, because the IRS classifies digital assets as property rather than as stock or a security, and §1091 by its terms applies only to stock and securities. This means, under current law, a crypto holder can sell at a loss and immediately repurchase the same asset without the wash sale disallowance a stock investor would face. This is not guaranteed to remain the law indefinitely; Congress has periodically proposed extending wash sale treatment to digital assets, but no such change had been enacted as of this writing.
- LIFO and average-cost methods. This calculator compares FIFO and HIFO specifically, the two most commonly discussed methods for crypto. Some taxpayers or software also support LIFO or average-cost methods, which are not modeled here.
- Holding period and short-term versus long-term character. This calculator computes the size of the realized gain only; it does not track how long each lot was held or split the result into short-term and long-term components for tax-rate purposes. See this platform's Crypto Capital Gains & Loss Calculator for a version that adds that holding-period tax computation.
- Wallet-by-wallet cost-basis allocation under Rev. Proc. 2024-28. As noted above, current guidance requires per-wallet tracking starting with 2025 transactions; this calculator treats all entered lots as one pool.
- More than four lots. Active traders routinely accumulate far more than four lots; this calculator illustrates the mechanics with four representative lots, and a full tax return typically needs dedicated crypto tax software to track every actual lot.
- Transaction fees. This calculator assumes cost basis per unit already includes any purchase-side fees, and that the sale price entered is net of any selling fees.
Common Pitfalls
- Choosing HIFO after the fact because it produces a better number. Specific identification requires contemporaneous designation of the lot being sold, not a retroactive choice made at tax-filing time once you already know every method's result.
- Assuming your exchange's default report used the method you actually want. Many exchanges generate 1099 forms or gain/loss reports using FIFO by default; if you have proper specific-identification records and want to use HIFO, you may need to override the exchange's default report rather than filing it as-is.
- Forgetting the wallet-by-wallet requirement that took effect for 2025. A cost-basis calculation that pools lots across multiple wallets or exchanges, the way many holders tracked basis before 2025, is no longer the compliant default method going forward.
- Believing the crypto wash sale loophole is permanent. It reflects current law based on crypto's classification as property, not a policy choice that is guaranteed to stay unchanged; legislative proposals to close it have recurred in recent years.
- Not keeping records at all. Without adequate purchase records for every lot, a taxpayer may not even be able to substantiate FIFO cleanly, let alone qualify for HIFO; documentation from day one is the foundation the entire method choice depends on.
Frequently Asked Questions
Can I just pick whichever method gives me the smallest tax bill?▸
Does the wash sale rule apply if I sell crypto at a loss and buy it back immediately?▸
What changed with IRS Revenue Procedure 2024-28?▸
Why does the same sale produce such different gains under FIFO versus HIFO?▸
What if I sell more units than exist across all my entered lots?▸
Sources
- Internal Revenue Service, Notice 2014-21 (virtual currency treated as property for federal tax purposes). https://www.irs.gov/pub/irs-drop/n-14-21.pdf
- Internal Revenue Service, Revenue Ruling 2019-24 (specific identification and lot-selection guidance for virtual currency). https://www.irs.gov/pub/irs-drop/rr-19-24.pdf
- Internal Revenue Service, Revenue Procedure 2024-28 (wallet-by-wallet cost-basis safe harbor and allocation, effective for the 2025 tax year). https://www.irs.gov/pub/irs-drop/rp-24-28.pdf
- Internal Revenue Code §1091 (wash sale rule, applicable to stock and securities); §1221-§1222 (capital assets, holding period, character of gain).
- Internal Revenue Service, Digital Assets guidance hub. https://www.irs.gov/filing/digital-assets