  In this paper, we construct a solution to the optimal contract problem for
delegated portfolio management of the fist-best (risk-sharing) type. The
novelty of our result is (i) in the robustness of the optimal contract with
respect to perturbations of the wealth process (interpreted as capital
injections), and (ii) in the more general form of principals objective
function, which is allowed to depend directly on the agents strategy, as
opposed to being a function of the generated wealth only. In particular, the
latter feature allows us to incorporate endogenous trading constraints in the
contract. We reduce the optimal contract problem to the following inverse
problem: for a given portfolio (defined in a feedback form, as a random field),
construct a stochastic utility whose optimal portfolio coincides with the given
one. We characterize the solution to this problem through a Stochastic Partial
Differential Equation (SPDE), prove its well-posedness, and compute the
solution explicitly in the Black-Scholes model.
