function z=lenderpayoff(v_bar,x_star,eta,c,mu,sigma)

%v_bar: face value of the debt contrast
%x_star: bankruptcy cutoff;
%eta: percent of assets retained in bankruptcy by the borrower
%c: Bankruptcy cost


%below are the upper and lower bounds for project realizations. If we
%choose a normal or a T-distribution for the project, then x_lbar must be
%sufficiently low and x_bar sufficiently large such that almost no
%probability mass is outside [x_lbar,x_bar]
x_lbar=-10;
x_bar=10;

z=quad(@(x) (1-eta).*x.*density(x,mu,sigma),x_lbar,v_bar/(1-eta))+quad(@(x) v_bar.*density(x,mu,sigma),v_bar/(1-eta),x_bar)-quad(@(x) c.*density(x,mu,sigma),x_lbar,x_star);
