Sources: Raptors agree to deal DeMarre Carroll, picks to Nets for Justin Hamilton

In a move to create salary-cap flexibility, the Toronto Raptors have agreed to trade forward DeMarre Carroll to the Brooklyn Nets, league sources told ESPN.

For the Nets to take on the two years and $30 million left on Carroll's contract, the Raptors will attach a 2018 lottery-protected first-round and second-round pick to the deal, league sources said.

The Nets will send center Justin Hamilton to Toronto in the trade, sources say. The Raptors will then waive and stretch Hamilton after acquiring him, league sources tell ESPN.

The Nets don't have the salary-cap space to complete the trade until Washington has officially matched the $106 million offer sheet for Otto Porter. The Wizards plan to extend the hold on Brooklyn's cap space by slow-playing the results of the physical exam Porter needs to pass. Toronto will also be held up in free agency because of the wait for Brooklyn.

This is the second significant contract that the Nets have absorbed into salary-cap space to obtain a young player or assets. The Nets made a deal with the Los Angeles Lakers for center Timofey Mozgov and the $46 million still owed him in order to obtain talented young guard D'Angelo Russell in the deal.

Because the Boston Celtics own the Nets' 2018 first-round pick, there was no benefit to Brooklyn tanking and getting a high pick in the draft. With the Carroll trade, the Nets are back in the 2018 draft with a first-round pick.

Carroll, 30, will have a chance to become the Nets' starting small forward. A hard-working veteran, Carroll could serve as a good mentor for 2016 first-round pick Caris LeVert. Nets coach Kenny Atkinson coached Carroll as an assistant with the Atlanta Hawks and holds a strong affinity for him.

The signing of Carroll was a free-agent coup for the Raptors in the summer of 2015, but injuries limited him to 26 games in his first season with the team. Toronto is still interested in becoming active in free agency this summer, according to league sources.

Toronto re-signed Kyle Lowry and Serge Ibaka, and let forward Patrick Patterson leave for a free-agent deal with Oklahoma City.