The Phillies spent just $50,000 two winters ago on a little known second baseman who had yet to play above double A. It was a slight gamble to see if Odubel Herrera could learn to play center field and stick in the majors for an entire season after being acquired in the Rule 5 draft.

Their risk was right and it led the Phillies and Herrera to take a chance on each other on Thursday. The Phillies signed Herrera to a five-year contract, locking him into their long-term plans. Herrera signed the deal — which, according to a source, guarantees him $30.5 million — knowing that he could possibly make more in arbitration and free agency.

Herrera was not eligible for arbitration until after next season and was not set to be a free agent until after the 2020 season. He is the first Phillies player with less than three years of service time to sign a major contract extension since Cole Hamels before the 2009 season.

The contract buys out Herrera's three arbitration years and his first year of free agency at what should be a club-friendly price. The contract includes a pair of club options that could keep Herrera with the team through 2023. The option according to a source, is worth $11.5 million in 2022 and $12.5 million in 2023.

Herrera, who will turn 25 later this month, will enter 2017 as the team's centerfielder. He made strides there last season and graded well in the team's defensive metrics. Herrera was the club's lone all-star, batting .286 with a .361 on-base percentage in his second major-league season.

He ranked second among National League centerfielders in hits (167), runs (87), and assists (11.) Over the last two seasons, Herrera leads all Phillies in batting average (.291), OPS (.773), hits (314), runs (151), doubles (51), stolen bases (41), and total bases (452). He has certainly outplayed the $50,000 chance the team took to get him from Texas in the Rule 5 draft.

One advanced metric places a high value on Herrera, which could have compelled the Phillies to explore such a deal. His 8.0 wins above replacement from 2015-16 was the second-highest ever by a Phillies player in his first two seasons, according to Baseball-Reference. A common industry value would pay a free agent $8 million per every one WAR. Herrera, who made close to the league minimum the last two seasons, would have played at a level that was worth more than $60 million over his first two years by that measurement.

According to MLB.com, WAR measures a player's value in all facets of the game by determining how many more wins he would be worth compared with a replacement-level player at his position.

If the options are honored to raise the total value to $54.5 million, Herrera will forfeit his first three years of free agency and would not test the open market until he is 32. The guaranteed money was too much to refuse for a player who was set to make the league minimum for a third straight season and grew up poor on a farm in Venezuela. And the guaranteed money is worth the risk for a team that invested so little just to take a chance.