Cost basis can refer to two different things:
The acquisition cost of a coin/asset bought
The acquisition cost of a coin/asset sold
Cost basis - coin/asset bought
The acquisition cost of a coin bought is calculated as the fair market value (FMV) of the coin/asset sold.
4000 USD → 1 BTC
The cost basis for 1 BTC acquired is $4,000.
2 BTC → 25 ETH
The cost basis for 25 ETH acquired is the FMV of 2 BTC at the time when the transaction happened.
Cost basis - coin/asset sold
The acquisition cost of a coin sold is calculated according to the selected cost basis method. In most countries, the default calculation method is First-in First-out, also referred to as FIFO.
There are special rules for calculating cost basis in certain countries like the UK and Canada for example.
We have written several in-depth guides about this topic. We recommend starting with this guide to learn more: Cryptocurrency Tax Calculations: What is FIFO, LIFO, and HIFO?