The San Francisco Giants have agreed to a contract extension with Wilmer Flores that guarantees the infielder $16.5 million over the next three seasons and could be worth up to $21.5 million.

Flores gets salaries of $6.5 million each in 2023 and 2024. The contract also  includes an $8.5 million club option for 2025. If the team declines, Flores has a $3.5 million player option.

The 31-year-old is hitting .233/.317/.410 with a career-high 18 home runs in 463 at-bats this season.