As part of the deal , JPMorgan and the Federal Reserve will guarantee the enormous trading obligations of the troubled firm , which was driven to the brink of bankruptcy by what amounted to a bank run .