Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Potential "Corrupt" pool. Mismatch between tick and sqrtPrice #650

Open
NoUJoe opened this issue Jun 12, 2023 · 5 comments
Open

Potential "Corrupt" pool. Mismatch between tick and sqrtPrice #650

NoUJoe opened this issue Jun 12, 2023 · 5 comments

Comments

@NoUJoe
Copy link

NoUJoe commented Jun 12, 2023

https://bscscan.com/address/0xd32db42675c921531d4faa925e82be2c85845f6e#readContract

at time of writing:

"sqrtPrice": "76243620223535651510009976419",
"tick": "-769",

According to TickMath.getTickAtSqrtRatio(). tick should be -768. I know -769 has 69 in it but it's still incorrect (I think)

@ashutosh887
Copy link

I would like to work on this @NoUJoe

@NoUJoe
Copy link
Author

NoUJoe commented Jun 12, 2023

@ashutosh887 Go for it! Me and you will single-handedly fix v3 between us!

@NoUJoe
Copy link
Author

NoUJoe commented Jun 12, 2023

I haven't tracked down where abouts the mismatch originated from. Somewhere in UniswapV3Pool.sol contract tho

@NoUJoe
Copy link
Author

NoUJoe commented Jun 12, 2023

State of the pool has changed now, but heres the swap history of the pool. Most recent swap is first

{
"id": "0x2cc29340fdfd5d2f891f2b9ba0eeeef8fc0a1c1497488722df270217e9ece71f#13",
"sqrtPriceX96": "46773420013045919332527908149680",
"tick": "127621",
"timestamp": "1686573753",
"amount0": "0.000001670924509181",
"amount1": "-1.166593134491446602"
},
{
"id": "0xa412a412db14c4c94b8ce77d5e216dfeeb3349d54996e52bfdc42a7c176eb09d#12",
"sqrtPriceX96": "93705710924737217324609070479279",
"tick": "141518",
"timestamp": "1686573753",
"amount0": "-0.000001659692530154",
"amount1": "1.162840149035734784"
},
{
"id": "0x5abe50b517f8f62b9b660244a88bd0cf41840f8157cf5f5aaf1778fee01b8db8#11",
"sqrtPriceX96": "46929081550081977323528726065053",
"tick": "127687",
"timestamp": "1686573681",
"amount0": "-0.002043072281690759",
"amount1": "1.164734591420462398"
},
{
"id": "0x963940a264fafcf3380bd26e637f6a16a8d1dcda1122b132d8954733fa9798f0#10",
"sqrtPriceX96": "76245975137296033629620969305",
"tick": "-768",
"timestamp": "1686556436",
"amount0": "-0.000000047250804423",
"amount1": "0.000000043764028216"
},
{
"id": "0xfe808053ff79d083293b682a5de0418f917b08a90b56da66eb554c57aed1b73a#9",
"sqrtPriceX96": "76244214677159280533203048997",
"tick": "-768",
"timestamp": "1686556436",
"amount0": "-0.000000008571659305",
"amount1": "0.000000007938914726"
},
{
"id": "0xdd94e4b4ea4245c15e23a09d572608459ba9e1557e0d7b4539b1d9257edf17eb#8",
"sqrtPriceX96": "76243895324863044148069426180",
"tick": "-768",
"timestamp": "1686555754",
"amount0": "-0.000000007383987108",
"amount1": "0.000000006838861048"
},
{
"id": "0x613f8d81bc62a44b5f457450a4961d20dbdba60ca58470a8a55ffada47e796c1#5",
"sqrtPriceX96": "76243620223535651510009976419",
"tick": "-769",
"timestamp": "1686438620",
"amount0": "2.388761863506896711",
"amount1": "-2.388550420327224272"
},

{
"id": "0xe9a70eebdd5350f9c2e125282e2a8cb95884b7475065f3afc6a8fe56fc0bcfa1#4",
"sqrtPriceX96": "79229072476916109107453723196",
"tick": "0",
"timestamp": "1686436610",
"amount0": "-2.38499583461392593",
"amount1": "2.385261793740156587"
},
{
"id": "0xfd1c151d4cff58e7804f7638e3bf996a73625c4819c659f98f231daf2a0bce6f#3",
"sqrtPriceX96": "79228163857998703525337530783",
"tick": "0",
"timestamp": "1686436592",
"amount0": "2.38221098928556964",
"amount1": "-2.382000131735133047"
},
{
"id": "0xb1fc2cf10fcfbfe1c887149921b17ab89d53d13e05baba1ea73bf42f6620d068#2",
"sqrtPriceX96": "79229071325196359269962464619",
"tick": "0",
"timestamp": "1686436592",
"amount0": "-2.385499920893261173",
"amount1": "2.385765861087683518"
}

Swap where mismatch occured is bold

@elee1766
Copy link

elee1766 commented Jul 9, 2024

this is possible in normal conditions, and not a corrupt state.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants
@elee1766 @NoUJoe @ashutosh887 and others