We present a network model of the interbank market in which optimizing risk averse banks lend to each other and invest in non-liquid assets. Market clearing takes place through a tâtonnement process which yields the equilibrium price, while traded quantities are determined by means of a matching algorithm. We compare three alternative matching algorithms: maximum entropy, closest matching and random matching. Contagion occurs through liquidity hoarding, interbank interlinkages and fire sale externalities. The resulting network configurations exhibits a core-periphery structure, dis-assortative behavior and low clustering coefficient. We measure systemic importance by means of network centrality and input-output metrics and the contribution of systemic risk by means of Shapley values. Within this framework we analyze the effects of prudential policies on the stability/efficiency trade-off. Liquidity requirements unequivocally decrease systemic risk but at the cost of lower efficiency (measured by aggregate investment in non-liquid assets); equity requirements tend to reduce risk (hence increase stability) without reducing significantly overall investment.