Correction: The third paragraph has been changed to fix an error in Square's financial results.

NEW YORK (TheStreet) -- It may not be a great time for Square to go public, but the company is actually doing much better than one might have supposed.

The San Francisco-based payment-processing company's financials have been the subject of heated speculation for years. But the IPO paperwork it filed with the Securities and Exchange Commission  on Wednesday shows it has the classic profile of a "hot" IPO--that is, once you strip out a money-losing deal with Starbucks (SBUX - Get Report) that expires in the third quarter of 2016, and perhaps even sooner.

That little adjustment fairly transforms the numbers: Square made a small second-quarter EBITDA profit. The numbers were already improving. Overall, Square's EBITDA loss was $19.3 million in the first half, much smaller than the $44 million loss a year earlier.

Despite losing money, the Starbucks deal served its purpose, which was to validate Square for smaller merchants. Unlike Starbucks, which could dictate stiff terms, smaller retailers lack the same heft, so Square can negotiate more favorable arrangements.

Looked at properly, Square is the veritable picture of what IPOs are supposed to look like: Fast-growing, just turning profitable on a cash basis, and with all of its major financial metrics showing how the business will achieve economies of scale as it grows.

Some examples:

Sales growth. Square said first-half sales rose 51% year-over-year to $560.7 million. Factoring out Starbucks, that's a 58% jump to $497.7 million. In other words, Square's very likely to have its first billion-dollar year in 2015.

Gross margins. The gross margins on the Starbucks deal are actually negative--so Square's margin structure looks much better without it. Absent Starbucks, gross margins are 35.9%, up from 34.7% in the first half of last year. With Starbucks, gross margin is 29.4%.

EBITDA. Square generated $859,000 in EBITDA in the second quarter, excluding Starbucks--its first profit for any period the prospectus covers, and probably the first in the six-year old company's history. Even with Starbucks, operating cash losses narrowed to $10.7 million for the first six months of the year, from $50.7 million for the first half of 2014.

Technology IPOs work, historically, when the companies are just getting big enough to cover their fixed costs, so that each new dollar in revenue begins to produce much wider profit margins than before, while still growing rapidly enough to promise that the fatter margins will add up to real money in future profits.

Unless the issuer is an outlier like Alphabet/Google (GOOGL - Get Report) (GOOG - Get Report) or Facebook (FB - Get Report) , which will sustain near-hypergrowth sales gains for a long time, investors want to get the stock before the company is solidly profitable - when it is, the early money will have already been made by someone else.  Square's numbers show that it fits the description.

Naturally, this strategy carries the risk that the nearly-mature company will bobble its adolescent stages - that's what happened at Twitter (TWTR - Get Report) , where Square CEO Jack Dorsey took on a second CEO job this month. Twitter fell Wednesday once Square's IPO paperwork became public.

The caveat is that this rule of thumb gets suspended, sometimes, when the market is skittish. Just last week, the IPO for Pure Storage (PSTG - Get Report) stumbled out of the gate after pricing at $17 a share, even though it too had the classic features of fast growth, a big market and fast-improving margins. So it's not certain investors will appreciate Square right away. For one, some may need to be convinced Dorsey can run Square and Twitter simultaneously. And the prospectus tells us nothing about the IPO price - if it's too high, investors might balk even in good times.

What we did learn was that Square has established what looks like a firm and growing niche in the payments market, and that it appears to have figured out how to do it profitably. With Silicon Valley pouring venture capital into all manner of payments companies, that's a sign that if the stock market likes Square it will see more startup companies like it going public -- and soon.

This article is commentary by an independent contributor. At the time of publication, the author held no positions in the stocks mentioned.