I was watching the state of the WETH-DAI pool on Ropsten which was (10435607102899899961933, 422393388012675303130025) and its 0.3% fee.
So its market maker k = 4407931440163027853157049123245748733249338325.
Then I sent 1000000000000000 WETH to it making the pool state changed to (10435617102899899961933, 422388295347420373432664) and the k changed to 4407882518992274291481223238881530978138779512.
Can anyone let me know why the k not keeping its value unchanged by definition?
The so called "constant-product" formula is deceiving since the K value will actually change on each transaction because of Uniswap's 0.3% fee. It's only a constant product if there's no fee involved.
The fee is deposited as liquidity in the pool, and adding liquidity to the pool changes the K value which is what you're seeing.
I found this article to be useful in explaining how the K value is affected in different scenarios.