SANTA CLARA >> Defensive end Nick Bosa has agreed to the richest contract in 49ers history, ending a 43-day holdout in what truly was a fait accompli for a franchise that’s investing so much toward its first Super Bowl title since the 1994 season.

The mega-deal comes just ahead of the regular-season opener, Sunday at the Pittsburgh Steelers.

Bosa’s five-year, $170-million extension includes $122.5 million guaranteed, ESPN first reported.

Coach Kyle Shanahan learned of the deal just minutes before meeting with the media and an hour before Wednesday’s practice. General manager John Lynch, along with contract czars Paraag Marathe and Brian Hampton, informed Shanahan in his office, eliciting “a couple of bro hugs,” Shanahan said with a smile.

Bosa, who Shanahan said is en route to the 49ers facility, is fully expected to play Sunday. Otherwise, “He’d need to have a beer belly and be out of shape, which is not in Bosa’s DNA,” said Shanahan.

When asked how many snaps Bosa might play, the “pumped up” coach replied: “How many snaps are in the game? No, knowing Nick he’ll be in great shape. We’ll be smart with it and base it on the next two practices.”

Bosa, the reigning NFL Defensive Player of the Year, waited out training camp before taking his rightful place among other 49ers earning top-of-the-market rates. At $34 million annually, Bosa is the highest-paid defensive player and non-quarterback in NFL history.

The 49ers, unlike many of Silicon Valley’s other venture capitalists, are funding a project that’s approaching its third decade without the ultimate return: a Super Bowl triumph.

Also playing this season on big-money deals are tight end George Kittle, linebacker Fred Warner, left tackle Trent Williams, fullback Kyle Juszczyk, cornerback Charvarius Ward, and defensive tackles Arik Armstead and Javon Hargrave.

Add up all the cash the 49ers are committing this season — close to $260 million — and it’s the price you pay when loading up and retaining top-tier talent for a long-awaited sixth Lombardi Trophy.

“We’re aware of the business side of it. We understand we have a fantastic football team with great core values at really important positions,” Kittle said early in training camp. “We understand the (championship) window, whatever that is, could be closing. We’re going to try our best just to keep that window as open as long as we possibly can, but we’re going to try sneak out some wins while that window is still open.”

The 49ers’ last Super Bowl win coincided with the 1994 installation of the salary cap — at a mere $34.6 million. That is almost as much as the Los Angeles Rams’ annual salary to Aaron Donald, a three-time NFL Defensive Player of the Year and the standard bearer for Bosa’s deal.

Bosa was set to make close to $18 million on the fifth-year option of his 2019 rookie deal. Bolstering his leverage: a career-high 18 ½ sacks last season, giving him 43 sacks since that 2019 NFL Defensive Rookie of the Year debut.

Bosa, it’s believed, has spent the past month working out at the gym he and his older brother, Joey, built in Fort Lauderdale, Fla., where they fanatically train each offseason rather than take part in their teams’ voluntary programs. Joey Bosa is three years removed from signing an extension with the Chargers (five years, $135 million) which stood as the market’s best until T.J. Watt corralled a bigger salary (four years, $112 million) from the Pittsburgh Steelers just days before the 2021 opener.

Steve Wilks, the 49ers’ first-year defensive coordinator, expects an easy assimilation for Bosa’s return, saying during camp: “You guys have been around here longer than I have and I’ve seen it from afar, but I think he’ll be fine when he gets here.”

The 49ers, after back-to-back runner-up finishes in the NFC, open defense of their NFC West title when the regular season begins Sunday in Pittsburgh.