Jamie Dimon and U.S. Treasury Secretary Janet Yellen were on a call Tuesday when Yellen floated an idea: What if the nation’s largest lenders deposited billions of dollars into First Republic Bank, the latest firm getting nudged toward the brink by a depositor panic.

Dimon was game — and soon the chief executive officer of JPMorgan Chase & Co. was reaching out to the heads of the next three largest U.S. lenders: Bank of America Corp., Citigroup Inc. and Wells Fargo & Co.

All month, the nation’s banking giants have been raking in deposits from nervous customers at smaller firms — and now those behemoths would be taking some of their own money and handing it to a San Francisco bank in distress, trying to stanch a widening crisis.