Inequality, Leverage and Crises: The Case of Endogenous Default