Interbank markets and their optimal regulation