Smart Contract liquidity rebase: Query in AMM price model

My Smart Contract has the rebase function which reduces the X coin supply in the Pancakeswap liquidity pair every 4 hours. Doing this to increase the price of the X coin. But the price model AMM was not working as expected.


Initial liquidity

X * Y (BNB) = K (Constant)

20, 000 * 0.2 = 4000

If the contract reduce the X supply to 10,000 then liquidity will be

10,000 * 0.2

Now if user needs to buy 1 X, then the user should pay (0.2 BNB) so that K will reach the constant value right?

4000(K) % 9999(X) = 0.4(Y)

9,999 * 0.4 = 4000

But it is not working in this way, Pancakeswap calculates the price of 1X by 0.2 % 9,999.

Please give me clarification.


Hi, welcome! :wave:

Emmmm, actually, In you case, there is an equation equation: 10000 * 0.2 = (10000 - buyAmount) + (0.2 + payAmount), and if the token pair has a low liquidity, when you try to buy a large amount, there will be a large slippage. And I am not familiar with the Pancake, so I do not know how do they charge fee and how much is the fee.