The optimal covenant threshold in loan contracts