DeMarcus Cousins was sleepless and confused in Las Vegas.

The four-time NBA All-Star was an unrestricted free agent who was supposed to be as coveted as anyone available other than LeBron James and Paul George. Sure, “Boogie” was recovering from a torn Achilles tendon and has a reputation for being emotional and prone to technical fouls. But the New Orleans Pelicans free agent also averaged 25.2 points, 12.9 rebounds and 5.4 assists last season while shooting 3-pointers better than most guards.

It was 5 a.m. Pacific time on Monday morning and nearly 90 degrees Fahrenheit. And a wide-awake Cousins was standing on the balcony of his offseason home alone.

“I was shocked. I didn’t believe it. It was a rough, pretty emotional night,” Cousins told The Undefeated in a phone interview on Monday night.

Just before the sun peeked in on another sweltering Vegas day, Cousins called his longtime agent Jarinn Akana with a shocking plan. How about signing the midlevel exception with an elite team? How about giving the reigning NBA champion Golden State Warriors a call, despite the fact that they already had four All-Stars, to see if they were interested?

“I was f—ed up,” Cousins said. “I said to Jarinn, ‘Let’s make a call.’ He was shocked. It was very insulting to not receive an offer. But I understand. I prepared myself for this.”

So around 8 a.m., Cousins said he called Warriors general manager Bob Myers. This is not a misprint. Myers cannot talk about free agents until they can sign with teams on Friday. But when Myers can speak, boy, does he have a story to tell.

Imagine Myers picking up his cellphone and a man with a deep voice says, “Hey, this is DeMarcus Cousins … got a minute?”

“It was very insulting to not receive an offer.”

Apparently, Myers did. But all the over-the-salary-cap Warriors could offer Cousins was the midlevel exception of $5.3 million for one season. Keep in mind that Cousins made $18 million last season. Keep in mind that before suffering a season-ending Achilles tear in January, the Mobile, Alabama, native was expected to be offered a five-year, $150 million contract extension from the Pelicans.

But months later, a recovering Cousins said Pelicans general manager Dell Demps told him he did not plan to re-sign him. Cousins said other possible teams told his agent that he was not the right fit or they were worried about his injury long term. The Pelicans committed to sign free-agent forward Julius Randle to a two-year, $18 million contract. It will certainly be interesting to hear what Pelicans All-Star forward Anthony Davis thinks of the departure of his close friend Cousins and point guard Rajon Rondo, who signed with the Los Angeles Lakers.

“Bob deserves all the credit for making this happen real fast,” said one member of the Warriors who asked not to be identified.

Cousins has played with Warriors All-Stars Kevin Durant, Stephen Curry, Draymond Green and Klay Thompson with USA Basketball. After talking to Myers, Cousins said, he spoke to Durant, Curry and Green, who is vacationing in Greece, to tell them he was considering joining the Warriors with the midlevel exception. A day after James shocked the NBA world by joining the Lakers and the Pacific Division, Durant, Curry and Green enthusiastically told Cousins they would welcome him to the Warriors with open arms.

Last season, the Warriors rotated journeymen Zaza Pachulia and JaVale McGee at center. Now, the Warriors have a center who is a skilled two-time All-NBA selection who can initiate the fast break.

“Steph was so freaking excited,” Cousins said. “Every one of those guys was excited.”

ESPN’s Chris Haynes reported that Cousins chose between signing with the Warriors and the Eastern Conference power Boston Celtics. Cousins declined comment on which teams were in his final mix. After getting the blessing from Durant, Curry and Green, Cousins said, he called Myers after 5 p.m. and told him he would accept the Warriors’ midlevel exception.

“A winning culture and togetherness got us DeMarcus,” Durant told The Undefeated via text.

Cousins said: “This was my ace of spades. This was my chess move.”

The breaking news on Cousins seemed to be fake news at first to Kings guard De’Aaron Fox before his summer league opener against the Lakers in Sacramento, California, on Monday. But once Fox realized it was true, he basically saw it as the rich getting richer.

“I looked at the alert on my phone and I didn’t believe it at first. And then all of the sudden I was getting a bunch of text messages about it,” Fox said.

Several members of the Warriors had smiles on their faces during and after a 79-68 win over the Miami Heat on Monday night in the House that Cousins Built. They wouldn’t say why they were smiling, but you knew it was Boogie-related. Young and athletic Warriors center Damian Jones believes Cousins will fit in well since he has experience with Durant, Curry, Green and Thompson with USA Basketball.

“He’s a dynamic player. One of the best players in the league. So that should be great,” said Jones, who had 14 points and six rebounds in 24 minutes.

Kings center Willie Cauley-Stein, who attended the summer league game, was also shocked to learn that his former teammate took the midlevel exception to go to the Warriors. Before trading Cousins to New Orleans during the 2017 NBA All-Star break, the Kings were expected to sign Cousins to a $200 million maximum contract.

“It’s a business, man,” Cauley-Stein told The Undefeated. “I’m sure he is excited. I was shocked, especially $5 million. But Godspeed. God willing, it will work out the way it is supposed to and he will end up getting what he deserves.”

On Jan. 26, Cousins had 15 points, 13 rebounds and 11 assists before tearing his left Achilles tendon in the final seconds of a 115-113 win over the West power Houston Rockets. That win was the Pelicans’ seventh in the previous eight contests. While the future appeared bright with Cousins and Davis, there was talk in New Orleans that the Pelicans were better without Cousins after they advanced to the West semifinals. Cousins and coach Alvin Gentry scoffed at such talk.

Cousins told The Undefeated on May 18 that his rehabilitation from Achilles surgery was ahead of schedule and he hoped to be ready for training camp. While it will be interesting to see what timetable the Warriors will have for their newcomer, Cousins still says he plans to be ready to play when training camp begins in Oakland, California, in late September. The Warriors have historically erred on the side of caution with injuries and can certainly afford to let Cousins take his time returning because of their depth.

“I’m shooting for training camp. It’s not B.S. It wasn’t a comment just to sound good in free agency,” Cousins said.

Cousins to the Warriors will likely be a one-year experiment for an NBA powerhouse that has won three titles in the past four years. If Cousins is healthy and plays at an elite level, he can hit the free-agent market again next summer seeking a big contract.

But Boogie to the Bay Area will soon be a reality. Believe it or not.

“I feel amazing. The crazy thing is it has been tough for me. But I’m just happy to be with the champs,” said Cousins, who has never played in the postseason.