Content pfp
Content
@
0 reply
0 recast
0 reaction

Adam pfp
Adam
@adamtj-xyz
one question for a point of clarity on uni pools token 0 <> token 1 these tokens are lexicographically sorted by their addresses. what is the reasoning behind sorting tokens in a pool like that? particularly in terms of the sc design choice there
1 reply
0 recast
0 reaction

Haardik pfp
Haardik
@haardikkk
simplify and say a pools are identified only by token pair to maintain state, you'll need to have two mappings 1. Token 0 => (Token 1 => PoolState) 2. Token 1 => (Token 0 => PoolState) to avoid this, a deterministic sorting algo is used to keep the state mapping uni-directional
1 reply
0 recast
0 reaction

Haardik pfp
Haardik
@haardikkk
this is also not new btw and has been done for many versions of uniswap See screenshot from Uniswap v2 codebase:
1 reply
0 recast
0 reaction

Haardik pfp
Haardik
@haardikkk
in v4 because pools have more parameters they're identified by (fee, hook address, etc) - we use the hash of an abi.encoded PoolKey to represent a pool if tokens were not sorted, there would be two hashes for the same pool with same tokens except 0 and 1 flipped around same issue
0 reply
0 recast
0 reaction