He wasn't declining, in fact he probably played his best hockey the following year in Long Island.
He is older but 1 year left on a contract is low risk.
The Bruins weren't in cap trouble yet. And if you want to talk about cap implications, remember the Bruins retained money in the Lucic deal. That has value.
A #2 RHD with 1 year remaining isn't relevant to another #2 RHD with 1 year remaining but one of the league's premier power forwards who was dealt with money retained is somehow an exact match?
Lucic was signed at market value, Shattenkirk is signed significantly below market value. You want to argue retention, then Blues retaining $750k-$1m on Shattenkirk would make a direct comparable.
Shattenkirk is a premier player, Boychuk is a talented player but would never have the value of Shattenkirk. 45-50 point defenseman, 3 years younger and a position of need for many teams. That excludes the fact that Boston were trading Boychuk at a time when they weren't wanting salary in return and right at the start of the season, which is the worst possible time to refuse to take salary in return.
As you said, Lucic is a premier power forward, Shattenkirk is a premier RH PMD... You're going to argue that a power forward hold much more value than a 45-50 point defenseman?
Whatever the case, if someone isn't willing to pay the price then he won't be traded.