Taking your point even further, you can raise the cost basis of your house by all the improvements you made to the house while you lived there. If you added a $50k pool to a $400k home, your cost basis is now $450k.
Further, you can deduct all the sales commissions (real estate 6% fees) from the profits as well.
You deduct the sales commissions because that’s money you lost in the round-trip. (Your profits were actually reduced by the amount you paid in commissions and we tax profits/gains.)