Bank of America Corp. agreed Friday, Jan. 11, to buy troubled mortgage lender Countrywide Financial Corp. about $4 billion in stock, another sign the banking market is slowly mopping up its subprime mortgage mess .

The largest U.S. bank by market cap buyer put out a statement saying Countrywide shareholders would receive 0.1822 of a Bank of America share for each share they now hold. That values each Countrywide share at $7.16, which is a 7.6 percent discount to the closing price Thursday, but 31 percent more than Wednesday’s close. The shares had nosedived Wednesday on reports that Countrywide, the largest U.S. mortgage lender, may be preparing to seek bankruptcy protection.