Congratulations, taxpayers! Fannie Mae and Freddie Mac, the mortgage-finance companies whose September 2008 bailout set off a financial fireball, just repaid you in full. You even made a small profit from your $187.5 billion loan.

The companies are throwing off torrents of cash as once-debased assets recover value in the housing revival. So more payback is coming, right?

Not necessarily. Hedge funds, mutual funds, insurance companies and other Fannie and Freddie shareholders are suing to stop the U.S. from using the profits to enhance taxpayer returns.

The Treasury Department, some of the country's leading constitutional lawyers claim, has no legal right to reward taxpayers ahead of shareholders. That's chutzpah. If the government owes a duty to anyone, it is the American taxpayer.

OK, that's not exactly a legal analysis. It is, however, a financial one, rooted in one of capitalism's basic principles: Those who risk the most deserve to reap the highest returns.

Taxpayers took on enormous risks - $5.4 trillion in debt and mortgage guarantees, to be precise - when Treasury Secretary Hank Paulson placed Fannie and Freddie into conservatorship. By doing so, he put taxpayers behind the companies' loan guarantees and made sure that, even though the private sector was abandoning the mortgage business, homebuyers could still get loans.

Under the deal, Fannie and Freddie shares kept trading, but holders ceded all rights to the U.S. government, which received just shy of 80 percent of the stock. The government also got an annual dividend equal to 10 percent of what each company borrowed from the U.S., plus $1 billion. The two were so mired in losses ($109 billion in total, more than their combined earnings in the prior 37 years) that they sometimes had to borrow from the Treasury to pay the annual dividend - to Treasury!

To end that farce, the U.S. in 2012 changed the terms of the arrangement by imposing a "net-worth sweep," in which it took every dollar of profit as its dividend. By depriving the companies of earnings, though, the U.S. also made it impossible for Fannie and Freddie to repay their government loans. It also deprived shareholders of dividends.

This is what the lawsuits are all about. More to the point, they are about Fannie and Freddie's $133 billion in 2013 earnings. The companies won't keep up that pace of profitability, but they are expected to earn about $179 billion more over the next decade.

That's a big pot of money. To get their hands on it, plaintiffs claim the U.S. essentially nationalized Fannie and Freddie when it amended their conservatorship. The plaintiffs also claim that documents from 2008, when the companies were seized, suggest that the U.S. would eventually return them to shareholders.

That's nonsense. No one involved in managing the 2008 crisis had a clue what would become of Fannie and Freddie, or whether they would ever be profitable again. If anything, the consensus was that the companies should never be allowed to revert to publicly traded companies in which shareholders get all the upside in the good times and taxpayers all the downside when the bubble bursts.

Hedge fund Perry Capital and others nevertheless claim that, as long-suffering shareholders, they deserve their share of those profits. Perry bought its shares for pennies in 2010, after Treasury failed to exercise rights to purchase them, speculating that it could make a bundle once housing prices rose and the companies exited conservatorship. Treasury, however, outsmarted the bottom feeders with the net-worth sweep. Now the investors want the legal system to hand them the windfall they had hoped for.

But Fannie and Freddie exist today solely because taxpayers for years covered their losses. The lawsuits are a distraction from the real debate: What should be done with Fannie and Freddie now that they are profitable again?

Paula Dwyer writes for Bloomberg View.