Matteo Iacoviello, Ricardo Nunes, and Andrea PrestipinoWe study optimal credit market policy in a stochastic, quantitative, general equilibrium, infinite-horizon economy with collateral constraints tied to housing prices. Collateral constraints yield a competitive equilibrium that is Pareto inefficient. Taxing housing in good states and subsidizing it in recessions leads to a Pareto-improving allocation for borrowers and savers. Quantitatively, the welfare gains afforded by the optimal tax are significant. The optimal tax reduces the covariance of collateral prices with consumption, and, by doing so, it increases asset prices on average, thus providing welfare gains both in steady state and around it. We also show that the welfare gains stem from mopping up after the crash rather than a pure ex-ante macroprudential aspect, aligning with prior research that emphasizes the importance of ex-post measures compared to preventive policies alone.