We study how securities and trading mechanisms can be designed to optimally mitigate the adverse impact of market imperfections on liquidity. Asset owners seek to obtain liquidity by selling their claims on future cash-flows, on which they have private information. Our analysis encompasses both the cases of competitive and monopolistic liquidity supply. In the optimal trading mechanism associated to an arbitrary given security, issuers with low cash-flows sell their entire holdings of the security, while issuers with larger cash-flows are typically excluded from trade. By designing the security optimally, issuers can eshew exclusion altogether. The optimal security is debt. Because of its low informational sensitivity, debt mitigates the adverse selection problem. Furthermore, by pooling all issuers with high cash-flows, debt also reduces the ability of a monopolistic liquidity supplier to exclude them from trade in order to better extract rents from issuers with low cash-flows.