0

First off, I'm fully aware of concentrated liquidity on Univ3. This is not a question about that.

Regardless of concentrated liquidity or not, it is my understanding that the swap price a Buyer is getting should always be lower than the price the pool ends up at after the swap, simply because you buy along a curve.

Some swaps do not seem to have this behavior. Take for instance the swap here

amount0 :-1279211354315689962871
amount1 :13000000000000000
sqrtPriceX96 :251314635170608008427270616
liquidity :43887562687655428171896
tick :-115074

Here token1 = ETH / token 0 = Party. Someone bought 1279.21 PARTY for 0.013 ETH, which amounts to 0.013/127921 = 0.00001016251 ETH/Party

However, the price ETH/Party after the swap is lower instead of higher, as calculated by: sqrtPriceX96^2 / 2^192 = 0.000010061.

I.e; price of pool ~1% lower after a buy, then the price the buyer got. How is this possible?

1 Answer 1

0

Your understanding on the prices is correct. Token's price after a swap that buys the token from the pool (P_end) is strictly greater than the initial price in the pool (P_start), and the average the price the swap is executed, which is equal to the P_swap = sqrt(P_start * P_end).

But your price calculation from the swap event is wrong. The amount0 and amount1 ratio from the swap event also includes fees paid by the buyer.

The actual amount of ETH used to buy the token is 99% of the transferred amount:

>>> 13000000000000000 * 99 // 100
12870000000000000

The price is P_swap = 12870000000000000 / 1279211354315689962871 = 1.0060886308255734e-05 which is less than P_end = 1.006181650599695e-05:

>>> 1.0060886308255734e-05 < 1.006181650599695e-05
True

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.