banner border
Koinly explains crypto tax and cost basis accountancy methods


Calculating Crypto Taxes: FIFO vs LIFO vs HIFO

Last updated: Thursday, 30 September 2021

If you're investing in crypto you'll very likely be up for Capital Gains Tax. Calculating just how much tax you need to pay has everything to do with the Cost Basis accounting method you choose. Each takes a different spin on calculating long term gains, profit and lost - and each country allows only certain cost basis methods to be used. So which cost basis method is right for you?

Capital Gains Tax

Let's start at the top. Your crypto investment is viewed as an asset by most tax authorities around the world.

When that asset changes hands - either by sale, swap or as a gift - this event is what's known as a disposal. If there is a profit at the point of disposal, the profit can be taxed as a capital gain.

Before you can arrive at a profit, you need to know what your Cost Basis was - in essence what the cost of the crypto asset was. This is a simple calculation:

Cost Base = cost of the crypto you bought + any fee that was involved in the acquisition of that asset, like a brokerage fee or a transaction fee.

Koinly explains crypto tax cost basis

If you buy 1 coin for nine hundred and ninety dollars, with a ten dollar transaction fee, your cost base is one thousand dollars. This cost base will be the baseline from which you measure any future profits.

Next, a capital gain is calculated by subtracting the price you bought the crypto for (cost-basis) from the price you are selling it for. 

Capital Gain = Selling Price - Cost basis. This seemingly simple formula becomes complicated when you add more transactions as we will see. The amount of tax you pay is a percentage of your total capital gains.

The best and easiest way of explaining the process of calculating your capital gains is through an example. So, in this article we are going to assume that, a fictional character, John has made the following crypto transactions and wants to calculate his capital gains and taxes.

IDTypeDateAmountPriceFeesCost basisCapital Gains
1Buy2018-01-010.25 BTC99 USD1 USD100 USDN/A
2Buy2018-05-200.50 BTC495 USD5 USD500 USDN/A
3Sell2018-06-010.50 BTC200 USD0??
4Sell2019-06-250.25 BTC400 USD10 USD??

The first step in determining John's capital gains is figuring out the cost basis of the sold cryptocurrency.

Calculating the Cost-basis

We know that John bought a total of 0.75 BTC for 600 USD. So, an easy way of calculating the cost-basis for each of the Sell transactions would be to divide the total cost by the total holdings.

This is known as Average Cost Basis (ACB). There are also other ways of calculating the cost-basis known as First In First Out (FIFO), Last In First Out (LIFO) and a special variant known as Specific Identification (Spec ID).

Let's look at how the cost-basis is calculated using each of these methods.

Capital gains using ACB

The Average Cost Basis (ACB) is the simplest of all accounting methods. The Average Cost Basis is calculated as the total amount paid to purchase the cryptocurrency divided by the total number of cryptocurrency held.

ACB is widely used in Canada and Sweden. It's also allowed in the UK, but under certain conditions - more on that here. In the US however, the Internal Revenue Service (IRS) does not allow investors to use ACB to arrive at the cost of crypto.

The cost-basis for John's two sell transactions can be calculated like this:

  • Transaction #3Sell 0.5 BTC. John has 0.75 BTC and bought it for a total of 600 USD. The average cost for 1 BTC is: 600 / 0.75 = 800 USD. So, the cost-basis for 0.5 BTC is: 800 x 0.5 = 400 USD.
  • Transaction #4Sell 0.25 BTC. At this point John only has 0.25 BTC left and bought it for: 600 (total cost) - 400 (already sold) = 200 USD. However, this sale also had a $10 fee so the actual cost-basis is $210.

Now that we have the cost-basis for all transactions, the capital gains can be easily calculated:

  • Capital gains for txn #3: 200 (selling price) - 400 (cost-basis) = -200 USD
  • Capital gains for txn #4: 400 - 210 = +190 USD

The final capital gains using ACB are -10 USD which means John made a loss of $10.

Capital gains using FIFO

First In First Out (FIFO) means you have to sell the coin that was bought first, first.

  • Transaction #3Sell 0.5 BTC. The cost basis can be calculated by taking the full cost of the 0.25 BTC txn (ID #1) and half of the cost of the second 0.50 BTC transaction (ID #2): 100 + (500/2) = 350 USD
  • Transaction #4Sell 0.25 BTC. Here the cost-basis calculation is picked up from the previous sell transaction. Since only half of the 0.50 BTC in txn ID #2 was sold, the remaining half will go towards the cost-basis for this one. Note that this transaction also has a 10 USD selling fee, so the cost-basis becomes: (500/2) + 10 = 260 USD

Let's calculate the capital gains:

  • Capital gains for txn #3: 200 - 350 = -150 USD
  • Capital gains for txn #4: 400 - 260 = +140 USD

Here the final taxable gains are 140 - 150 = -10 USD. Again, a loss of 10 USD.

Capital gains using LIFO

Last In First Out (LIFO) is the opposite of FIFO - here the most recently bought coins are sold first.

  • Transaction #3Sell 0.5 BTC. Cost-basis for this transaction is relatively straightforward, since the most recent purchase was for 0.5 BTC (txn #2) at a cost of 500 USD - this becomes the cost-basis.
  • Transaction #4Sell 0.25 BTC. As txn #2 was fully used as the cost-basis for txn #3, you now move to the crypto that was bought before it, which is the 0.25 BTC bought for 100 USD. The amount of crypto being sold and bought is the same so the cost-basis is simply 100 USD. However, you must add the selling fee of $10 so the final cost-basis becomes 100 + 10 = 110 USD.

The capital gains are calculated in the same way as FIFO/ACB:

  • Capital gains for txn #3: 200 - 500 = -300 USD
  • Capital gains for txn #4: 400 - 110 = +290 USD

The final capital gains are thus -10 USD.

Capital gains using Spec ID

Specific Identification allows you to pick the assets that you want to sell instead of simply relying on the date of purchase like with FIFO/LIFO. SpecID is generally used when selling stocks/bonds and is allowed by the IRS (United States) on the proviso that you can 'adequately identify' the lots that you are selling. It is not known if cryptocurrency holders can make use of it - as cryptocurrency is classified as property.

Lets look at a different example that can better demonstrate SpecID:


Alice bought 1 BTC for 1000 USD in January and another 1 BTC in Feb for 5000 USD. She sold 1 BTC in May for 4000 USD. Here are her transactions:

TypeDateAmountPriceCost basisCapital Gains
Buy2016-01-011 BTC1000 USD1000 USDN/A
Buy2018-02-011 BTC5000 USD5000 USDN/A
Sell2019-05-011 BTC4000 USD??

Alice has decided to use SpecID. She is aware that she must be able to identify the BTC that she is selling in order to make use of SpecID. To comply with this requirement, the 1 BTC she bought in January is stored in address 0x11111 and the BTC she bought in Feb is stored in 0x22222. This setup allows her to 'adequately identify' the lots that she is selling.

If she sells 1 BTC from 0x11111, her cost-basis would be +3000 USD (profit). If she sells 1 BTC from 0x22222, her cost-basis would be -1000 USD (loss). With this knowledge Alice is much better equipped to make tax-efficient trades.

Which method should you choose?

As you can see all methods resulted in a loss of -10 USD. However, this is due to the low number of transactions and the fact that all of the bitcoin was sold. Under real trading conditions the results of FIFO, LIFO and ACB can be quite different.

Ultimately the choice of method comes down to what is allowed in your country. If you are US based - you have several options but the most recommended and conservative one is FIFO. In countries where you are allowed to choose between different methods it is important to be consistent. You will need to pick a method and stick to it. It is generally quite difficult to switch a method and doing so usually requires authorization from the tax agencies.

Final words

With cryptocurrency tax reporting, the most crucial thing is to keep track of ALL your transactions and trades. If you are a daredevil you may attempt to do your crypto taxes with excel but be prepared to spend many hours on it - generating accurate crypto tax reports is a very time-consuming and elaborate process. We at Koinly have built a cryptocurrency tax solution that allows you to easily generate tax reports using the accounting method of your choice.

If you are interested in finding out more about how crypto taxation works, check out our tax guides. We have recently published a comprehensive guide on How crypto taxation works in the United States.


Get our stories delivered

From us to your inbox, weekly.