The deal, backed by the Swiss government, follows weekend-long talks aimed at preventing the bank's collapse.