How should capital income, labor income, and wealth be taxed in an economy with wealth inequality? Answering this question requires taking a stand on the source of wealth inequality. An extensive literature has argued that returns to capital which are stochastic at the level of individual household portfolios are needed to account for observed wealth inequality. I develop a model in which these stochastic returns arise from optimal incentive-compatible contracts with private information. To provide appropriate incentives, optimal contracts expose entrepreneurs partially to the idiosyncratic risk of the firm they manage. The government has access to linear taxes on consumption, capital and labor income and wealth and must use these revenues both to redistribute across agents and to finance government consumption. A quantitative version of the model is consistent with key features of the US data. Starting. from a steady state of this model, I numerically solve for the trajectory of optimal policies over time. Capital income taxes are small, and taxes on consumption and labor income are essentially constant. When consumption tax is not available as an instrument to the planner, capital income tax is at its upper bound for a short duration before dropping close to zero. These results are qualitatively close to neoclassical models without financial frictions.