On February 24, 2022, as Russia invaded, the National Bank of Ukraine switched from a flexible to a fixed exchange rate regime. Was this policy response optimal? To answer this, we develop an open-economy model with both nominal rigidities and frictions in borrowing on international financial markets. We find that the carefully calibrated model can rationalize the NBU’s decision: the optimal response to small shocks is to allow exchange rate flexibility, whereas in response to large shocks―such as an invasion―currency depreciation is suboptimal. For robustness, we consider tradable endowment, risk-premium, and non-tradable supply shocks, and add subsistence consumption.