A Model of Moral-Hazard Credit Cycles