SAN FRANCISCO -- Matt Cain and the San Francisco Giants have agreed to a $127.5 million, six-year contract, the largest deal for a right-handed pitcher in baseball history.