(Fortune) -- Until the recent tempest, Wall Street firms looked like just about the world's best businesses. Year after year, they posted sumptuous returns on equity, ever-rising share prices, and if you believed their claims, a new breed of CEOs who'd mastered the art and science of risk management. True, it was hard to decipher exactly how they made all that money. But make it they did.

The standards that rule most businesses�� - avoiding excessive leverage, reining in rampant pay and the massive dilution that goes with it�� - didn't apply to Wall Street. So what if investors didn't understand all those arcane instruments and sophisticated hedging strategies? Wall Street was the black box on the Hudson that worked its own brand of magic.

Today, the magic is fading fast. It's time to step back and analyze how financial firms actually operate.

The truth is that they've been relying on a highly-flawed business model for years. Put simply, Wall Street firms used towering leverage to make tons of money in a long-running bull market that blatantly underpriced risk. At the same time, they handed a huge chunk of the gains to employees in the form of excessive pay.

Now that run is over, and the price of risk is rising dramatically. That's driving down value of everything from junk bonds to mortgaged backed securities. Wall Street's addiction to leverage is cutting the wrong way. The Bear Stearns (BSC, Fortune 500) meltdown is a primer in the Wall Street curse: When portfolios are built on a mountain of debt, a firm's entire equity base can vanish overnight. The same curse is now taking its toll at Lehman (LEH, Fortune 500), Morgan Stanley (MS, Fortune 500), and Goldman Sachs (GS, Fortune 500).

So let's look at where Wall Street went wrong, and what it can do to redeem itself. Be warned. Redemption won't be easy. The three big weaknesses of Wall Street are deeply embedded in its culture.

First, firms rely far too heavily on trading as opposed to solid, reliable fee-based businesses favored by big commercial banks. As we'll see, one type of Wall Street trading is consistently lucrative. The rub is that firms always blow it on the risky trading.

Second, firms embrace leverage levels so dangerous that even the best risk management can't prevent a collapse.

Third, an outsize share of the gains go out the door to CEOs, CFOs and traders when times are good�� - or rather, when firms get lucky - ��leaving shareholders with far less wealth when markets go sour.

The first issue�� - trading�� - is complex. That's because a large part of Wall Street trading is a super money-maker, even if the way it's conducted is a drag for the average investor. A decade ago, Wall Street garnered most of its revenues from fee-based businesses, including M&A advisory, brokerage, equity and debt underwriting, and asset management. Today, over 60% of revenues flow from trading.

It's important to realize that trading falls into two distinct categories, call them part A and part B. Wall Street firms occupy a highly privileged position for viewing which investors are buying which stocks and bonds. That's because their primary clients, often through their prime brokerage businesses, are the world's biggest investors, mutual funds. Anyone who's worked as a Wall Street trader will tell you that the firms use their market intelligence to trade for their own accounts. Though the fund clients complain about the practice, they put up with it. So Wall Street firms enjoy an edge over the rest of us, and use it aggressively. This part of trading is incredibly, even consistently, lucrative.

If Wall Street stopped there, it wouldn't be facing its current crisis. The problem comes with Part B, trading that's potentially dangerous. Wall Street firms can't resist taking big positions in currencies, mortgage backed securities, oil futures, junk bonds or other speculative vehicles, especially when they're hot. It happened in the late 1990s with the Asian Contagion, the LTCM meltdown, and the Russian debt crisis, and again with the tech bubble. When risk premiums on those assets keep falling, as they did consistently from 2002 until the middle of last year, the Wall Street mavens look like geniuses.

But when the risk spreads expand suddenly and dramatically, the story of the last 9 months, the prices of those assets drop sharply. Wall Street leaders from Stan O'Neal, former Merrill Lynch (MER, Fortune 500) CEO, to John Mack, chief of Morgan Stanley, boasted that their firms' skills in risk management would prevent massive losses from proprietary trading, part B, as we call it.

But the enormous profits on the way up was a danger signal that Wall Street was playing on the edge. The losses on the way down are proof that either Wall Street isn't as good at hedging as it claims, or more likely, that too much hedging would spoil the huge profits it craves when markets are roaring.

Wall Street's second problem is its love of leverage. At the end of 2007, Morgan Stanley and Lehman had ratios of assets to shareholders' equity of 33 to 1, closely rivaled by 28 to 1 at Merrill. Again, it's the curse that felled Bear Stearns: If the value of the portfolios of any of these firms falls by 3%, their entire capital would be wiped out. To be sure, that massive leverage magnified gains mightily from 2002 to mid-2007. But today, it threatens to erase most, or even all, of their shareholders' wealth. The sad truth is that Wall Street managers aren't geniuses but big risk-takers who get lucky. Until they get unlucky.

It's the third problem, Wall Street's legendary largesse on pay, that encourages that outrageous risk-taking. The system rewards swashbuckling behavior from every level from traders to CEOs. If traders can generate big profits for a year or two by taking risky bets, they can collect bonuses big enough to retire on. In good years, top managers at places like Bear and Morgan Stanley collect grants of restricted stock and options far out of proportion to the size of their companies. For example, James Cayne, Bear's former CEO, collected almost $40 million in pay for 2006.

Once again, Bear's big profits were driven largely by excessive leverage and a frothy market, not, to put it mildly, by enlightened management. At most of the firms, the employees took 30% or more of the company through stock grants that they paid nothing for, leaving far less for shareholders.

So what's the solution? First, Wall Street must return to its roots in fee-based businesses. It would also do far better relying on part A type trading, though the ethics of that business are questionable, and it may fade as trading becomes more automated and electronic systems that allow clients to remain anonymous inevitably flourish.

Second, the current leverage ratios are irresponsible, and must come down. Indeed, Jamie Dimon forged his reputation as one of Wall Street's most prudent managers at Travelers by demanding that the investment bank limit its leverage.

Third, the compensation system must be revamped so that traders and managers bank their bonuses forward, so that they're only released if the firms are profitable over a sustained period of say, four or five years, not a single year. That reform is probably just a dream, given what stars expect on Wall Street. But it would favor shareholders over employees, a dream that's worth achieving.

The most probable result of all this turmoil isn't the reforms I've mentioned, at least not directly. It's that the already shrinking ranks of independent firms get swallowed up by big banks, either domestic or foreign. That's the system in Europe and Asia. It was only the artificial separation of investment and commercial banks that kept the Wall Street firms independent for this long. But Wall Street has blown it. Over time, big banks, boasting far more capital and far more discipline, will tame Wall Street. It just happened with JP Morgan (JPM, Fortune 500) and Bear. And that's just the beginning.