Deductions & credits

Your gain or loss on a home sale has nothing to do with a mortgage or a down payment.

 

Selling Price minus Selling Expenses minus Adjusted Basis of Home (Purchase price plus Improvements) equals Gain or Loss

 

See IRS Publication 523 Selling Your Home - https://www.irs.gov/pub/irs-pdf/p523.pdf