https://www.accointing.com/en-US/blog/crypto-cost-basis
Use a quote if you're going to copy-paste and entire article, you're going to get in trouble this way.
Accounting and IRS don't care about inputs or outputs or technical stuff.
It all depends on the taxation that your country uses or, in some cases it has multiple what they let you use.Without OP telling us from where he is this is a shot in the dark
If he is in the US he can use FIFO, first in first out, so if he has bought 10 batches of 10 BTC and decides to sell 5 he will pay tax on the profits compared to the first batch. If he sells 15 he will pay taxes on the first batch profits and on half of the second batch profits. In the UK the last time I checked they allowed Share Pooling so it means the median value of the bought coins versus the selling value.
So, it's all about the country's tax system.
Four hours spent each day for one week at the IRS and you'll come up with a solution.
Remember, it's your problem, not theirs, from their point of view if you can't prove you have paid anything for them then they will claim it's zero so you're going to pay tax on profits for the entire selling value.