However, what is the technique when the purchase price -more exactly, the cost basis- is known but the sale price and date are not? Let's say that I got 0.01 BTC for $500 in 2021 and I'm sure that I sold it later during the year, but don't know when or for how much. How do I calculate the gain?
Based on everything you presented, I'm guessing you were keeping it in a wallet that didn't belong to an exchange
[regardless of its nature]... I believe you can still find the missing information
[date and its price at the time of sale] by connecting the dots on an "
explorer [look where the output of the first transaction was used as an input]".