Capital flows often confront central banks with a dilemma: to contain the exchange rate or to allow it to float. To tackle this problem, an equilibrium model of capital flows is proposed. The model captures sudden stops with shocks to the country risk premium. This enables the model to deal with capital outflows as well as capital inflows. From the equilibrium conditions of the model, I derive an expression for the accounting of net foreign assets, which helps study the evolution of foreign debt under different policy experiments. The policy experiments point to three main conclusions. First, interest rate defenses of the exchange rate can deliver recessions during capital outflows even in financially resilient economies. Second, during unanticipated reversals in capital inflows, the behavior of foreign debt is not necessarily improved by containing the exchange rate. Third, an economy can gain resilience not by simply shifting the currency denomination of debt, but by both, shifting the denomination and floating the currency.