-
Notifications
You must be signed in to change notification settings - Fork 28
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
LpSugar: added Lp.root. #90
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm, just left one tiny nit
ec382c7
to
b120fdf
Compare
) | ||
) | ||
|
||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
TODO: replace all below with
https://github.com/pcaversaccio/snekmate/blob/main/src/snekmate/utils/create2_address.vy#L49-L76
Consider:
from snekmate.utils import create2_address
@internal
@view
def _root_lp_address(
_factory: address,
_token0: address,
_token1: address,
_type: int24
) -> address:
...
create2_address._compute_address(salt, init_hash, _factory)
|
||
salt: bytes32 = empty(bytes32) | ||
|
||
if _type < 1: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You could rewrite the if-else
block like this:
common: Bytes[72] = concat(convert(chain.id, bytes32), convert(_token0, bytes20), convert(_token1, bytes20))
salt = keccak256(concat(common, 0x00)) if (_type == 0) else keccak256(concat(common, convert(_type, bytes3)))
Probably the recommended approach consumes slightly more gas, but is definitely more readable imo.
08e29c2
to
4989852
Compare
84ae874
to
96fa367
Compare
Added
Lp.root
representing root (placeholder) pool address, for (non-canonical) leaf chain pools.