v4-core icon indicating copy to clipboard operation
v4-core copied to clipboard

refactor(Hooks): Update hook description and add test for new hook combination

Open penandlim opened this issue 1 year ago • 2 comments

Related Issue

Fixes #227

Description of changes

Fix incorrect NatSpec comments regarding example hook address in Hooks.sol library contract file. The description claims

/// For example, a hooks contract deployed to address: 0x9000000000000000000000000000000000000000 /// has leading bits '1001' which would cause the 'before initialize' and 'after swap' hooks to be used.

However this seems to be a typo as this would require shifting 1 by 159 and 156, which corresponds to BEFORE_INITIALIZE_FLAG and AFTER_MODIFY_POSITION_FLAG.

Confirmed the change is correct by running the new test with forge test --mt testValidateHookAddressBeforeInitializeAfterModify -vvvvv with console.log() added to view the hook address.

  [4626] HooksTest::testValidateHookAddressBeforeInitializeAfterModify(9034) 
    ├─ [0] console::log(0x900000000000000000000000000000000000234a) [staticcall]
    │   └─ ← ()
    └─ ← ()

console.log was then removed before adding to the PR for cleanliness.

penandlim avatar Jun 13 '23 18:06 penandlim

Feel free to merge if you're happy with it :)

hensha256 avatar Jun 14 '23 11:06 hensha256

Now sure if I have the permission to merge! Would love if someone from the team merged it for me :)

penandlim avatar Jun 16 '23 16:06 penandlim