Investors should be relieved. The world’s biggest shipbuilder can now avert a bankruptcy whose costs were sure to be damaging to the entire South Korean economy and financial system.

The bankers of Daewoo Shipbuilding & Marine Engineering Co. have finally managed to persuade a major bondholder to accept their restructuring proposal. Korea’s National Pension Service, which owns a quarter of the company’s 1.55 trillion ($1.4 billion) of debt securities, was holding out for repayment of a bond that matures Friday. Korea Development Bank, the policy lender that owns 79 percent of Daewoo Shipbuilding, had been threatening to push the company into bankruptcy in an attempt to persuade NPS to fall into line. Bondholders would have received next to nothing in that event.

The compromise solution calls for debt holders to swap 50 percent of their bonds and 80 percent of loans for equity. Plus NPS would receive about 200 billion won in exchange for 45 percent of the bonds maturing this month, according to Bloomberg News.

Investors in Korean banks should be happy. Daewoo Shipbuilding owes 1.6 trillion won to the country’s four largest commercial lenders by market value. Of the quartet, Hana Financial Group alone has a 700 billion won exposure.

Daewoo’s loans to Korea’s top 4 commercial banks: 1.6 trillion won

Having to write off 630 billion won of that—in addition to the 70 billion won of provisions already made—might have meant sacrificing 46 percent of Hana’s net income this year. Under a debt-to-equity swap, the hit should be a more palatable 20 percent, according to Nomura Holdings Inc.‘s calculations.

The agreement makes sense for all sides. Global trade is finally coming out of a multiyear funk. Singapore’s non-oil domestic exports jumped 16.5 percent last month, completing their longest winning streak in six years. With a little help from stable oil prices, last year’s drought of new orders at Korean shipyards should also end.

Daewoo will mark “the end of shipbuilding sector restructuring,” says Nomura’s Seoul-based analyst Michael Na. Unless something goes terribly wrong across the 38th parallel, 2017 should be a good year for Korea’s banks.

This column does not necessarily reflect the opinion of Bloomberg LP and its owners.