Shares in SoftBank fell 2.5% on Wednesday after the Japanese conglomerate confirmed a massive deal to bail out WeWork, the embattled office space startup.

The deal will give SoftBank up to 80% ownership of the beleagured startup. The Japanese company is pumping $5 billion into The We Company and accelerating a $1.5 billion equity investment originally due next year. It’s also offering to buy up to $3 billion worth of stock from existing investors and shareholders.

WeWork accepted the deal Tuesday in a story first reported by the Wall Street Journal.

The company has a large presence in the Research Triangle Park region and in Charlotte.

The deal would hand co-founder Adam Neumann nearly $2 billion in exchange for severing most of his ties to the office-sharing company

WeWork has been scrambling for cash since its attempt to enter the stock market floundered last month, a stunning fall from grace for a company that has until recently been considered one of the most highly valued start-ups in the U.S. The failed IPO cost WeWork $6 billion in promised financing from its banks, which had been contingent on the company raising at least $3 billion on the stock market.

WRAL TechWire photo

Inside WeWork Durham.ID.

“The board of WeWork, which was in danger of running out of cash in a matter of weeks, chose SoftBank’s financing over a competing offer from JPMorgan Chase,” reports venture capital news site PitchBook.

“The company faces tens of billions of dollars in rent payments. Various published reports have also cited WeWork’s plans, still in the works, to lay off as many as 5,000 people as it races to head off a cash crunch.”

The Softbank deal gives WeWork a lifeline as it attempts to turn around its money-losing business model. But the rescue package comes at a steep cost for Softbank, which already owned one-third of WeWork and has already sunk $10 billion into the company.

The Wall Street Journal reported that Softbank’s takeover would value WeWork at $8 billion, a fraction of the $47 billion valuation Softbank had assigned the company in its last round of financing last year. That means that Softbank is now investing more money into WeWork than the company is worth.

“This is where the math gets confusing because they’ve put in more money than the valuation of the company. I don’t know how that is being characterized on the balance sheet,” said Larry Perkins, founder and CEO of SierraConstellation Partners, a management advisory firm that specializes in helping companies navigate difficult turnarounds.

“That would be the question going forward: Is this good money after bad money or a preservation of their investment?” Perkins said.

Softbank will pay Neumann for $1 billion for his shares in the company and extend him $500 million in credit to help him repay a loan that had been extended to him by J.P. Morgan., the Journal reported. Softbank also will pay Neumann a $185 million consulting fee.

Neumann stepped down as CEO under pressure last month after the failed IPO but he still retained a controlling share of the of the company he co-founded nine years ago, making his approval necessary for any deal. He will step down from WeWork’s board of directors, but retain a small stake in the company.

“He gets a golden helicopter that lets him get out of this, and that is just remarkable,” Perkins said.

The deal with Softbank also has a $5 billion loan component, and Softbank will release early $1.5 billion in funding that had been scheduled to kick in next year, the Journal reported.

WeWork mostly makes money by leasing buildings and subdividing them into office space that it subsets on a short-term, flexible basis.

Its revenue has more than doubled annually over the last few years. But that came mostly through expensive lease acquisitions that put its flashy co-working spaces in 111 cities around the world. Meanwhile, its losses mounted almost as quickly as revenue, reaching $1.6 billion last year.

WeWork was sitting on $2.5 billion in cash and cash equivalents at the end of June, but it burned through nearly $199 million in the first six months of the year just operating its business.

On top of that, WeWork spent $2.36 billion on new leases and other investment, an amount that had been offset by $3.43 billion raised though venture capital and high-yield debt. The person familiar with the negotiations said WeWork had been on track to run out of cash by the end of November without the new financing.

Report: WeWork looks to raise $5B after putting off IPO