Bankrupt clean energy giant SunEdison plans to sell stakes in its two YieldCo units to Canadian investment firm Brookfield Asset Management, the companies announced on Tuesday.

Brookfield, which owns 260 renewable power plants, including 215 hydroelectric facilities, will acquire TerraForm Global outright for $787 million in cash, with the assumption of about $455 million in net debt. Brookfield will also increase its shares in TerraForm Power to 51 percent for $1.7 billion.

The deals still need to be approved by a bankruptcy court.

TerraForm Global owns and operates more than 30 wind and solar plants with a capacity of 952 megawatts across developing countries such as Brazil, China and India. TerraForm Power has close to 3 gigawatts of wind and solar farms across the U.S., the U.K., Canada and Chile.

YieldCos are publicly traded companies that own clean energy assets like solar and wind farms. YieldCos were once a popular way to use public markets to finance projects. But they fell victim to a boom-and-bust cycle in recent years after too many stock offerings hit the market simultaneously.

SunEdison previously sold off 1.5 gigawatts of its utility-scale solar and wind farms to NRG Energy for $183 million, as well as its solar commercial development team for $15 million to Japanese industrial giant Mitsui.

In April 2016, SunEdison declared bankruptcy after a spectacular rise and fall. As investors questioned the company's strategy after a planned acquisition of solar installer Vivint Solar for $2.2 billion, its stock price crashed. It sold off projects to stay solvent. Many of its deals, like the purchase of Vivint Solar, fell through.

The company is in bankruptcy court negotiating the sale of $20.7 billion in assets, plus liabilities of $16.1 billion. It was the one of the largest non-financial bankruptcies of the last decade.

On news of the Tuesday sale, TerraForm Power’s stock rose over 3.5 percent, while TerraForm Global’s jumped over 15 percent. SunEdison’s stock rose over 20% -- to 10 cents.

Despite SunEdison’s overreach and mismanagement, clean energy is still growing globally. Investment in clean energy hit $287.5 billion across the world in 2016, and much of that was from developers and investors funding solar and wind projects, according to Bloomberg New Energy Finance. The amount of wind and solar connected to the grid around the world grew 19 percent last year.

Read some of our previous coverage of SunEdison:

Correction: the story was changed to accurately reflect the value of the deal, from $2.5 billion to $1.4 billion. The change was due to a discrepancy in equity value for TerraForm.