We analyze the role of retail central bank digital currency (CBDC) and reserves when banks exert deposit market power and liquidity transformation entails externalities. Optimal monetary architecture minimizes the social costs of liquidity provision and optimal monetary policy follows modified Friedman (1969) rules. Interest rates on reserves and CBDC should differ. Calibrations robustly suggest that CBDC provides liquidity more efficiently than deposits unless the central bank must refinance banks and this is very costly. Accordingly, the optimal share of CBDC in payments tends to exceed that of deposits.