This paper considers the design of an optimal unemployment insurance system. The problem is modeled as a repeated principal-agent problem involving a risk-averse agent-the unemployed worker-and a risk-neutral principal, which cannot monitor the agent's search effort. The optimal long-term contract subject to the associated incentive constraints is characterized, This contract involves a replacement ratio that decreases throughout the unemployment spell and a wage tax after reemployment that, under some mild regularity conditions, increases with the length of the unemployment spell. Some numerical results are presented that suggest that the gains from switching to this optimal unemployment insurance scheme could be quite large. The performance of this optimal contract is also compared to alternative liquidity provision mechanisms.