Last year, Musk asked his Twitter (TWTR  ) followers if they thought he should sell off 10% of his Tesla (TSLA  ) shares. After the Twitter poll closed in favor of the sale, Musk began selling millions of his shares. Amid that sell-off, Musk reportedly gave just over $5.7 billion in Tesla shares to an unnamed charity or charities.

A recent filing with the U.S. Securities and Exchange Commission (SEC) revealed that Musk donated 5,044,000 Tesla shares between November 19 and Nov. 29 last year. Based on the closing value of the stock over those five days, the donation was worth roughly $5.74 billion.

Musk's stock sales, on the other hand, netted him a whopping $16.4 billion. This is actually about one million shares short of being 10% of Musk's holdings, the amount he pledged to offload. At the same time, Musk picked up roughly another 7 million Tesla shares by exercising his stock options that were set to expire.

A significant portion of the funds from Musk's stock sales will go towards paying off the tax burden on his exercised stock options, an $11 billion debt according to Musk himself.

This massive donation also has positive ramifications for how much the tech billionaire will owe in taxes. Unlike stock sales, these gifts are not subject to capital gains tax.

"His tax benefit would be huge," tax policy researcher at the Institute for Policy Studies, Bob Lord, said. "He'd save between 40% and 50% of the $5.7 billion in tax, depending on whether he could take the deduction against his California income and he'd avoid the gains tax he would have to pay if he sold the stock."

Lord added that there's no guarantee Musk's donations went to traditional charities. For instance, the $5.7 billion could have been given to "donor-advised funds". These funds allow donors to receive immediate tax deductions on charitable donations while giving input on what charities the fund should support.

While Musk has historically fallen far behind his fellow billionaires when it comes to charitable giving, his 2021 donation put him just below the Bill and Melinda Gates Foundation in total philanthropic aid last year. Billionaires George Soros and Warren Buffet have given away roughly 20% of their net worth as of last September. In comparison, Musk and Amazon (AMZN  ) founder Jeff Bezos had donated less than 1% of their wealth.

The Musk Foundation, the tech mogul's charitable organization, states on its site that it provides grants to support the "development of safe artificial intelligence to benefit humanity", among other things. In 2021, the organization gave $100 million in prizes for those working to improve technology meant to remove carbon from the atmosphere. Musk also stated that he would be giving $30 million to schools in the area around SpaceX in Texas.

Also last year, Musk butted heads with the United Nations World Food Programme after the executive director of the program, David Beasley, pleaded with Musk on Twitter to give a donation to the cause. In response, Musk wrote that if the program can tell him "exactly how $6 billion will solve world hunger" he would "sell Tesla stock right now and do it."