The math makes sense to me when you buy/sell assets from a pool with two assets without considering fees.
If we have a pool of 100 ETH and 300,000 USDC and someone buys 2 ETH, the pool will look like: 98 ETH and ~306,122.45 USDC (x•y=k stuff). So the buyer paid ~6,122.45 USDC for 2 ETH.
But usually about 0.1% of buying token goes to fees so 0.1% of 6,122.45 is ~6.12. So actually only 6,116.37 USDC (6,122.45 – 6.12) is added to the pool which throws off the K value. Since, 98•6116.37 doesn’t give us the K value we want. So how does the pool keep the balance with K while considering fees?
Any resources linking to this?
I would imagine the fee is just added on top of the swap values (after splitting it 50/50).
The fees get added to the pool. Also I think most AMMs charge 0.2 or 0.3% in fees
In your example, the pool has to be 50/50 so wouldn’t 2 ETH cost $3000 instead of $3061?
It sounds like you don’t understand basic programming… and that’s okay. Just accept that you aren’t ready for this yet.
Learning how variables work, how to update them, and how to make math functions are literally the first things you learn.