Financial contracts often specify reference prices whose values are undetermined at the time of contracting, which makes them prone to manipulation. To study such situations, we introduce a stylized model of financial contracting between a client, who wishes to trade a large position, and her broker. We find that a simple contract based on the volume-weighted average price (VWAP) emerges as the unique optimal solution to this principal-agent problem. This result explains the popularity of guaranteed VWAP contracts in practice and also suggests considerations for the optimal design of financial benchmarks.