Risk-reshaping contracts and stochastic optimization