In this paper, we take up the analysis of a principal/agent model with moral hazard introduced in \cite{pages}, with optimal contracting between competitive investors and an impatient bank monitoring a pool of long-term loans subject to Markovian contagion. We provide here a comprehensive mathematical formulation of the model and show using martingale arguments in the spirit of Sannikov \cite{san} how the maximization problem with implicit constraints faced by investors can be reduced to a classic stochastic control problem. The approach has the advantage of avoiding the more general techniques based on forward-backward stochastic differential equations described in \cite{cviz} and leads to a simple recursive system of Hamilton-Jacobi-Bellman equations. We provide a solution to our problem by a verification argument and give an explicit description of both the value function and the optimal contract. Finally, we study the limit case where the bank is no longer impatient.