China's moves to weaken its currency in an "orderly fashion" and boost slowing economic growth is costing a lot of money, and the world's second-largest economy has been selling U.S. Treasurys to help finance the efforts, analyst Peter Boockvar told CNBC on Friday.

As a result, China has ceded the title of largest holder of U.S. Treasury debt to Japan. Boockvar said on "Squawk Box" it remains to be seen how that shift plays out. "We need [China] to finance our debts and deficits" in the United States.

The People's Bank of China on Friday set the midpoint rate for the yuan at the lowest level in 8½ years. President-elect Donald Trump has been railing against Beijing for keeping its currency low to give China a trade advantage over the U.S.

"They've been repatriating money back, they've been trying to intervene by selling dollars [and] buying yuan" to provide support, as China looks to ease the currency lower, said Boockvar, chief market analyst at The Lindsey Group.

Money has been escaping China "for a variety of reasons, and they've been trying their best to, yes, weaken the currency, but make it happen in an orderly fashion," which means limiting overseas investments, he added.

At the same time, China has been working to halt the slide in its roaring economy, which expanded at an annual rate of 6.7 percent in the third quarter, basically matching forecasts and the rates growth of the previous two quarters.

The Communist government has targeted growth this year in the 6.5 to 6.7 percent range, after expanding at a 6.9 percent rate in 2015, which was the slowest pace in 25 years.