The Yankees weren’t supposed to contend in 2017 — not after selling at the 2016 trade deadline and building a farm system rich in both quality and quantity, which they would use to compete later on. It was the franchise’s first admission in decades that it was ready to sacrifice present-day gains for future successes, and just a few months after seeing players they traded pitch in the World Series for the Cubs and Indians, they didn’t seem ready to capitalize on those future promises yet. Then Aaron Judge happened, and Luis Severino broke out, and the Red Sox couldn’t pull away in the AL East. And the Yankees became buyers once again.

Two weeks ago, they made their first move, dealing with the White Sox to solidify their infield with Todd Frazier and create a dominant bullpen with David Robertson and Tommy Kahnle. On Monday, an hour before the trade deadline, the Yankees patched their other outstanding roster hole, trading three well-regarded prospects for Oakland starter Sonny Gray (and $1.5 million in international signing money). The righty didn’t come cheap, but he does come with both present and future upside for a team in a precarious place on the win curve. Let’s break down the deal.

Sonny Gray’s Fit in New York

Other playoff contenders — the Dodgers, Astros, and Nationals — have built division leads that all but assure them playoff berths, meaning they could focus on making trades to boost their playoff rosters. The Yankees, though, sit just half a game ahead of Boston in the division and 3.5 games ahead of Tampa Bay in a possible wild-card race, and they couldn’t afford to focus only on October. With Michael Pineda out for the season because of a torn UCL, New York had been using the combination of Caleb Smith and Luis Cessa at the back of the rotation, which both put the team at a disadvantage every five days and taxed the bullpen.

Adding both Gray and Jaime García, for whom the team sent Minnesota a pair of backend pitching prospects over the weekend, assures New York a viable starter in every game going forward. But unlike García, who was unlikely to feature in the playoffs anyway and is a free agent after this season, Gray provides short-, medium-, and long-term value. For the short, he’s been on fire lately, with a 1.37 ERA and .164 batting average allowed over his last six starts. For the medium, he could slot behind Severino as the team’s no. 2 pitcher in a playoff rotation. And for the long, he is under contract for two more years after this one, giving the Yankees coverage if CC Sabathia, the now-injured Pineda, and possibly Masahiro Tanaka — if he exercises his opt-out clause — all leave this offseason.

That final factor is perhaps the biggest boost to Gray’s stock in New York, as the youthful Yankees are still better positioned to compete for a championship in the next couple seasons rather than this one. But even in the nearer future, Gray compares favorably to, say, Yu Darvish, the other top starter traded on deadline day. The two AL West hurlers have identical career ERAs (3.42) in roughly the same number of innings (782.2 for Darvish, 705 for Gray); Darvish strikes out more hitters, but Gray walks fewer and allows fewer home runs. And while Yankee Stadium is a much tougher park for pitchers than Oakland’s Coliseum, Gray is about as well suited as a pitcher can be to counter his new stadium’s home run factor. Out of 168 qualified starters since 2013, when Gray debuted in the majors, he has the 12th-highest ground-ball rate and 17th-lowest hard-hit rate allowed. Over that same span, for comparison, Darvish has the 135th-highest grounder and the 122nd-lowest hard hit rates.

Gray throws one of the most effective sinkers in the majors, and while his lack of breaking ball consistency means he’s not quite an ace, his current arsenal of pitches profiles well for his new ballpark. Gray should also receive help from an improved defense behind him: Both this year and last, Oakland was the worst defensive team in the majors as measured by both DRS and UZR, while this year’s Yankees rate near average by both metrics.

Oakland’s Haul of High-Risk, High-Reward Prospects

In large part because Gray is an affordable starter for three more Octobers, New York had to dip into its pool of highly touted prospects to complete the deal. The Yankees traded starter James Kaprielian, shortstop Jorge Mateo, and center fielder Dustin Fowler, who, by FanGraphs’ rankings, rated as the fourth-, sixth-, and seventh-best prospects, respectively, in the Yankees system heading into this season. And those rankings came on New York’s talent-flush farm, meaning they could all have been top-three prospects in another organization.

While Oakland had reportedly been interested in more established prospects like Clint Frazier, currently swatting extra-base hits in the Bronx, it settled on a trio of high-risk, high-reward youngsters. Kaprielian drew rave reviews this offseason after boosting his fastball velocity from the lower to upper 90s, but he has pitched just 56 professional innings since being drafted in the first round in 2015 and underwent Tommy John surgery in April. Baseball America placed Mateo 26th on its overall preseason prospect rankings in 2016, but he had lost much of his prospect shine with a year-and-a-half-long slump until upping his production at Double-A over the last month. And Fowler, who was the rare overlooked prospect in New York, is out for the season after rupturing his right patellar tendon while chasing a foul ball in his very first MLB inning.

Those three prospects could all become valuable contributors in Oakland: They represent a potential front-of-the-rotation arm and two up-the-middle bats. But they could also all continue on their injury-prone and inconsistent tracks — as is the danger with all minor leaguers, but especially these three.

Though New York’s prospect pool took a hit on Monday, the Yankees still boast a top minor league system. But amassing top prospects isn’t only about promoting them all to the majors one day; it’s about increasing flexibility so that a trade for a young, cost-controlled starter is possible without sacrificing the team’s future. The Yankees didn’t expressly need Sonny Gray to compete this year or in 2018 and 2019, but he improves their chances. New York probably won’t sell again anytime soon.