-
Notifications
You must be signed in to change notification settings - Fork 485
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
Test lockless posm via hooks #266
Conversation
5e998cc
to
87b9da0
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.
looks great!
test/shared/PosmTestSetup.sol
Outdated
@@ -24,12 +25,26 @@ contract PosmTestSetup is Test, Deployers, DeployPermit2, LiquidityOperations { | |||
HookSavesDelta hook; | |||
address hookAddr = address(uint160(Hooks.AFTER_ADD_LIQUIDITY_FLAG | Hooks.AFTER_REMOVE_LIQUIDITY_FLAG)); | |||
|
|||
HookModifyLiquidities hookModifyLiquidities; | |||
address hookModifyLiquiditiesAddr = | |||
address(uint160(Hooks.BEFORE_SWAP_FLAG | Hooks.AFTER_ADD_LIQUIDITY_FLAG | Hooks.AFTER_REMOVE_LIQUIDITY_FLAG)); |
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.
it only has a before swap hook?
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.
it inherits HookSavesDelta
i wrote a test where if a hook burns a position, it should have the principal capital of the original position. so needed the hook-delta-saving functionality
/// @dev hook can burn liquidity with approval | ||
function test_hook_burn() public { | ||
// mint some liquidity that is NOT burned in beforeSwap | ||
mint(config, 100e18, address(this), ZERO_BYTES); |
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.
Whats the point in this mint that doesnt get burned?
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.
because we're burning a position in beforeSwap, if there is only 1 position the swap will fail haha (all liquidity was burned JIT)
need some "idle" liquidity thats untouched for the swap to succeed
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.
LOL good catch
* actions with no unlock * Test lockless posm via hooks (#266) * test hook which modifiesLiquidities in beforeSwap * test hook modifying liquidity * minor cleanups * test that hooks cannot re-enter modifyLiquidities * hook mints liquidity with modifyLiquidities * PR cmments * rename * rename * Update src/interfaces/IPositionManager.sol Co-authored-by: Sara Reynolds <[email protected]> * misc code comments --------- Co-authored-by: saucepoint <[email protected]> Co-authored-by: saucepoint <[email protected]> Co-authored-by: Sara Reynolds <[email protected]>
Description of changes
hookData
is passed tomodifyLiquidities
(lockless posm)Follow up tests:
#265