Per the CBA reached in January 2013, teams receiving a “cap advantage” from long-term contracts (defined as seven years or more) will be penalized in the event the player retires or “defects” from the NHL before the contract expires. A team receives a “cap advantage” when the player’s actual salary exceeds his cap hit in a given year. Please note, contracts that fall under the "over-35" rule do not qualify for cap benefit recapture, the NHL has confirmed. In these cases, the team is charged with the player's full cap hit. CapGeek's recapture calculator helps determine whether a team is on the hook for a recapture penalty and if it is, how much:
If Roberto Luongo retires or defects in the 2018 off-season (age 39 as of July 1 that year), and was traded to the Florida Panthers in the 2013 off-season, following is an estimated breakdown of the recapture penalties for the involved teams.
Vancouver Canucks (2018-19 through 2021-22) $7,430,000 $1,857,500
Florida Panthers (2018-19 through 2021-22) $6,903,333 $1,725,833
IMPORTANT NOTES [ Edited June 2, 2013 ]: Teams do not receive a credit for net negative cap benefit (where cap hit exceeds salary over the course of the contract prior to retirement). However, in calculating net "cap advantage," teams do receive a credit for seasons in which cap hit exceeds salary ... Calculations for players who have been traded during the season are rough estimates based on best information available and may differ from actual league numbers.
Now, if Luongo is bought down the road you'd have to assume no cap recapture as he didn't retire or defect from the contract