CryptocurrencyInvestingBanksReal Estate

Bank of America is making money on its financial crisis settlement

May 23, 2014, 3:28 PM UTC

FORTUNE — When Bank of America announces its next quarterly profit, it is likely to have a $138 million gain from an unlikely source: It’s multi-billion-dollar settlement with the government.

In late March, the bank agreed to pay the Federal Housing Finance Authority $9.5 billion to settle claims that it sold defective bonds to Fannie Mae (FNMA) and Freddie Mac (FMCC), the government-controlled mortgage entities the agency regulates. Bank of America (BAC) is also reportedly in the process of negotiating a settlement with the Department of Justice that would resolve the government’s other remaining financial crisis-related investigations against the giant mortgage bank. That payment could be as large as $13 billion.

But if the FHFA deal is any guide, the fine that BofA ultimately ends up paying won’t be as costly as it looks.

MORE: How Bank of America lost billions and forgot to tell the regulators

BofA paid FHFA $9.5 billion, but a little over a third of the settlement, $3.2 billion, went toward repurchasing troubled mortgage bonds that had been sold by BofA (or Countrywide or Merrill Lynch — both of which were acquired by BofA) and bought by Fannie and Freddie. That was usual.

BofA is the fifth bank to settle mortgage claims with FHFA, but it’s the first that involves a bank repurchasing bonds that it sold to Fannie and Freddie. Other banks have bought back individual loans or groups of loans that were defective.

What’s more, FHFA didn’t force BofA to repay Fannie and Freddie what it paid for the defective bonds and swallow the losses, as it did with other banks that bought back loans. Instead, BofA paid the current market price for the bonds, which on average was only about 20% of their original face value.

The bonds were certainly a bad investment for Fannie and Freddie. Two thirds of the mortgages in the 67 bonds that BofA repurchased from the mortgage insurance giants have either been written off, refinanced into better loans, or paid off.

But as the economy and housing market has recovered, distressed mortgage bonds have become a hot investment. And many of the bonds that BofA purchased in the settlement have done well recently. For instance, the price of one of the bonds, Merrill Lynch Mortgage Investors Trust Series 2007-HE5, a bundle of subprime home loans, has risen nearly 20% in the past year.

MORE: Wall Street and Washington can’t agree on whether they agree

Overall, according to an analysis prepared by a mortgage bond portfolio manager for Fortune, the group of bonds that BofA bought in the settlement from Fannie and Freddie are now worth $3,338,229,282.41, give or take. BofA has made $138 million on the bonds in nearly two months.

And that’s not all. The bonds have a remaining value of $5.2 billion. That means BofA stands to recoup as much as $2 billion if all the borrowers end up paying back their loans in full. That’s optimistic. On the Merrill Lynch 2007 trust, which is not the best performing of the group, a little over 11% of the remaining borrowers in the pool are delinquent on their loans. Not all of those will end up in foreclosure. But even if they do, and we use that as a guide for the rest of the bonds BofA purchased, the bank still stands to make $1.4 billion on the bonds it got from Fannie and Freddie.

“FHFA should have negotiated a profit sharing deal,” says the mortgage bond fund manager.

None of this is actually a profit, though it will show up on BofA’s books as one. After all, the bank’s total payment to FHFA was $9.5 billion. Factor in the bonds it got, along with the potential gains, and BofA’s net settlement bill with Fannie and Freddie’s regulator will be $4.9 billion.

But that seems like an extraordinarily good deal. FHFA’s suit against BofA alleged that the bank, along with Countrywide and Merrill Lynch, made misrepresentations on $57.5 billion in bonds that were sold to Fannie and Freddie. BofA’s settlement could end up costing the bank just 8.5% of that amount.

On average, other banks have settled for around 13% of the amount that FHFA says were faulty. JPMorgan (JPM), for instance, paid $4 billion when it settled its FHFA suit back in October, or about 12% of the $33 billion in bonds that FHFA claimed were mis-sold. And Countrywide had a much higher rate of foreclosure than other lenders, resulting in higher losses on those bonds. So you would have expected BofA to have to pay even more than those sums, not less.

The way post-financial crisis justice is doled out for Wall Street banks is a head-scratcher, indeed.