function z=lenderpayoffend(v_bar,eta,c,mu,sigma)

%Computes the payoff to the lender, substituting a value for x_star at
%which constraint (10) is satisfied.

x_star=optxstar(v_bar,eta,c,mu,sigma);
if x_star~=-99
    z=lenderpayoff(v_bar,x_star,eta,c,mu,sigma);
else
    z=0;
end;

