The nation’s largest banks made a killing in the mortgage business last year.

Earnings released in the past several days show mortgage activity accounting for about 15 percent of the profits at Wells Fargo (WFC). JPMorgan Chase (JPM), meanwhile, reported $418 million in profit from its mortgage banking business, compared with a loss of $269 million a year earlier. Even Bank of America (BAC), which has been retreating from the mortgage market, posted a 41 percent spike in loan originations in the fourth quarter, to $22 billion.