Endogenous risk in a DSGE model with capital-constrained financial intermediaries