That is correct, the code does swap the tokens for ETH or BNB or whatever the token happens to be paired with. But the source of BNB is the tokens liquidity pool. It’s not an external source of BNB.
In the same transaction this is what happens:
-The token contract starts with 500 Billion tokens
-The token contract initiates a swap and sends 250B tokens to it’s own Liquidity Pool and receives BNB in return.
-The token contract initiates the ‘addLiquidity’ function and sends ALL the BNB it just received, and the other 250B tokens back to the liquidity pool.
-The LP tokens are then sent to a privately held, unlocked developer wallet.
This all happens in the same transaction.
The end result is a liquidity pool that has 500B more tokens, but the exact same amount of BNB. This actually breaks the ‘Constant Product’ which is the mechanism determining the price of the token.
Here are 2 plots of liquidity pool price curves. On the left side is what the price curve should look like. The X & Y axis represent the Quantity of Token A & the Quantity of Token B in the liquidity pool. When a liquidity pool is first initialized the two quantities are multiplied and they create something known as the ‘constant product’. This number is supposed to be a Constant. The number of output tokens a trader receives for their input tokens is calculated such that after the trade, the product of the two liquidity pool reserves is the same as it was before the trade
This is a plot of the “Constant Product” for Safemoon. This should be a nearly flat line with an extremely slight slope due to the small fee paid to liquidity providers. Safemoon’s constant product plot is an uphill staircase. Each ‘step’ in the plot is one of these automatic token dumps. If you look closely you’ll see that the line is also sloping upward. This is because the liquidity pool is receiving token reflections. This further devalues the token and breaks the ‘constant product’. Also, the “rewards” paid to holders are actually a net loss due to how much these operations devalue the token.