MIAMI (AP) — Andre Iguodala’s trade to Miami was getting closer to the finish line Thursday after the Heat and Memphis Grizzlies agreed to terms on a six-player trade, according to two people with direct knowledge of the terms.

The portion of the trade involving Iguodala was agreed upon Wednesday night, as was the 2015 NBA Finals MVP agreeing to a two-year extension with Miami that will be formalized when the totality of the deal actually gets approved by the league sometime Thursday.

Justise Winslow knew he was leaving Miami for Memphis on Wednesday night, as evidenced by some social-media posts and a late-night visit to his now-former locker room to pack up his belongings and wish a security guard well. Also in the deal: Dion Waiters and James Johnson leaving Miami for Memphis, with Jae Crowder and Solomon Hill leaving the Grizzlies for the Heat.

Miami and Memphis were also working on a third component, that being adding Oklahoma City in what could have brought Danilo Gallinari to the Heat. But as Thursday’s 3 p.m. EST trade deadline neared, that deal remained simply an idea — so the Heat and Grizzlies were moving on to completing what they could.

Iguodala, speaking to The Undefeated on Wednesday night, said he was eager to play alongside Jimmy Butler and Miami’s young core while helping mentor them as well.

Jimmy Butler ... he’s looked at as different but (is) very well-respected in terms of the passion and the hard work that he brings to the game,” Iguodala said. “I feel like his temperament and values that he has really resonates with the Miami Heat. They’re very well aligned. I think he’s brought out the best in those young guys.”

Iguodala specifically mentioned Heat center Bam Adebayo, a first-time All-Star this year.

“Bam, I’m really looking forward to playing with him,” Iguodala said.

Butler and Adebayo, speaking after Miami’s loss in Los Angeles to the Clippers on Wednesday night, indicated they were excited to add Iguodala to their mix.

“He’s super-smart. There’s nothing that he cannot do,” Butler said. “When I get to learn from him, when everyone gets to learn from him, that winning level, that meter, is going up in everyone’s mind.”

Added Adebayo, who values his playoff experience: “You know he’s going to bring a lot of knowledge.”

Holding the team option for 2021-22 is a critical component of Iguodala’s extension for Miami, which intends to have maximum flexibility for free-agent shopping in the summer of 2021 and made clear to all teams in recent days — and even last summer — that it would not compromise those plans.

The 36-year-old Iguodala was traded to Memphis last summer. He did not play for the Grizzlies, after he and the team agreed that it would be best if he was sent elsewhere. It took seven months, but Miami became that next destination.

“He won, what, three championship rings?” Heat guard Goran Dragic said. “Happy to have him. Can’t wait to pick his brain. He’s going to do great things for us.”

Winslow has been with the Heat for five seasons, missing most of his second season with a shoulder injury and missing most of this year with a back problem. Johnson is returning to Memphis after spending 2013-14 with the team, and was with Miami for parts of four seasons. Waiters, who had been suspended three times by the Heat this season, also was with Miami for parts of four years.

Combined, those three players had scored only 254 points for Miami this season.

The Heat went into the trade deadline prioritizing perimeter defensive help, which made Iguodala a perfect fit. It was not immediately clear when he would join the Heat, which began a five-game trip in Los Angeles with a 128-111 loss to the Clippers on Wednesday night.

“He’s another person like Jimmy that I could lean on because he knows the ropes and knows everything on the defensive end,” said Derrick Jones Jr., who had 25 points against the Clippers. “He’s one of those people that I could pick his brain on the defensive end. He has a very high IQ.”

Crowder and Hill were both held out of Memphis’ win over Dallas because they were likely to be involved in the pending trade — they knew they were headed somewhere, though the Miami part was not completely clear until Thursday.

Grizzlies coach Taylor Jenkins, without commenting specifically on the still-not-completed transaction, said Crowder and Hill “really helped build something great here in Memphis.”

Grizzlies guard Dillon Brooks, who said earlier this week that he was looking forward to playing against Iguodala one day “and show him really what Memphis is about,” said he was eager to play with Winslow.

“We’re getting a good player,” Brooks said.

Miami would be the fourth team that Iguodala has suited up for, joining Philadelphia, Denver and Golden State. He has averaged 12.1 points in 1,108 career games, plus is a veteran of 145 playoff contests and was with the Warriors for all five of their NBA Finals runs over the last half decade.

He’s a three-time champion and two-time All-Defensive team member, and getting him is a clear sign that the Heat are expecting to be a postseason contender.

“Excited to get back out there,” Iguodala said.