Toronto Maple Leafs center Auston Matthews has signed one of the most lucrative second contracts in the salary cap era, agreeing to a five-year, $58.17 million extension with the Leafs through the 2023-24 season. Matthews, 21, would have been a restricted free agent this summer.

The average annual value of the contract is $11.634 million. That's second in the league behind Connor McDavid's $12.5 million. Matthews' teammate John Tavares is now third at $11 million.

There's nothing like playing in Toronto. So proud to be a Leaf. pic.twitter.com/TrGeNQ7xRF — Auston Matthews (@AM34) February 5, 2019

Toronto still has to come to terms with forward Mitch Marner, who is in the final year of his rookie contract and leads the team with 63 points in 52 games.

Matthews has 23 goals and 23 assists in just 38 games this season. He was the first overall pick of the 2016 draft and has been an All-Star in each of his three seasons. He had 40 goals as a rookie and 34 last season when injuries limited him to 62 games.

For Matthews, 93 percent of the new deal will be paid in signing bonus money, which is lockout, rollback and buyout protected. That includes $40.1 million in signing bonuses in the first three years of the deal.

At the NHL All-Star Game, Matthews said he wasn't concerned about the deal getting done.

"It's something that's in the back of your mind. When it gets done, it gets done. I'm not too worried about it. When my agent calls me and says we're ready to sign, then I'll sign," he said.

Highest AAV: current NHL contracts Connor McDavid $12.5M Oilers Auston Matthews $11.6M Maple Leafs John Tavares $11.0M Maple Leafs Jonathan Toews $10.5M Blackhawks Patrick Kane $10.5M Blackhawks Carey Price $10.5M Canadiens

As a percentage of the salary cap, Matthews' contract is a blockbuster. The average annual value of the deal would be 14.6 percent of the current cap of $79.5 million. That's higher than the second contracts for Edmonton Oilers center Leon Draisaitl (11.3 percent) and Buffalo Sabres center Jack Eichel (13.3 percent) when they were signed. The average annual value of McDavid's second contract with the Oilers was 16.6 percent of the cap.

The key difference between Matthews' deal and the deals for those players, of course, is term. Rather than commit to an eight-year max contract, the Leafs decided to sign him to a deal that brings him right to unrestricted free agency, in an effort to create some added financial flexibility for a team that already is committed annually to Tavares through 2025 and has to sign the 21-year-old Marner to his second contract.