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

add salt to modLiq event #818

Merged
merged 2 commits into from
Aug 5, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1 +1 @@
144447
144728
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
170646
170924
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😞

2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
273803
274080
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
134911
135192
Original file line number Diff line number Diff line change
@@ -1 +1 @@
292624
292905
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24386
24393
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity CA fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
140945
141223
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with empty hook.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
130421
130693
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity with native token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
112308
112532
Original file line number Diff line number Diff line change
@@ -1 +1 @@
98640
98921
2 changes: 1 addition & 1 deletion .forge-snapshots/simple addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
161164
161445
Original file line number Diff line number Diff line change
@@ -1 +1 @@
92728
93009
2 changes: 1 addition & 1 deletion .forge-snapshots/simple removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
84829
85110
2 changes: 1 addition & 1 deletion src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,7 @@ contract PoolManager is IPoolManager, ProtocolFees, NoDelegateCall, ERC6909Claim
callerDelta = principalDelta + feesAccrued;

// event is emitted before the afterModifyLiquidity call to ensure events are always emitted in order
emit ModifyLiquidity(id, msg.sender, params.tickLower, params.tickUpper, params.liquidityDelta);
emit ModifyLiquidity(id, msg.sender, params.tickLower, params.tickUpper, params.liquidityDelta, params.salt);

BalanceDelta hookDelta;
(callerDelta, hookDelta) = key.hooks.afterModifyLiquidity(key, params, callerDelta, hookData);
Expand Down
3 changes: 2 additions & 1 deletion src/interfaces/IPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,9 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload {
/// @param tickLower The lower tick of the position
/// @param tickUpper The upper tick of the position
/// @param liquidityDelta The amount of liquidity that was added or removed
/// @param salt The extra data to make positions unique
event ModifyLiquidity(
PoolId indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta
PoolId indexed id, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta, bytes32 salt
);

/// @notice Emitted for swaps between currency0 and currency1
Expand Down
37 changes: 24 additions & 13 deletions test/PoolManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,12 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
event UnlockCallback();
event ProtocolFeeControllerUpdated(address feeController);
event ModifyLiquidity(
PoolId indexed poolId, address indexed sender, int24 tickLower, int24 tickUpper, int256 liquidityDelta
PoolId indexed poolId,
address indexed sender,
int24 tickLower,
int24 tickUpper,
int256 liquidityDelta,
bytes32 salt
);
event Swap(
PoolId indexed poolId,
Expand Down Expand Up @@ -99,13 +104,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
function test_addLiquidity_succeedsIfInitialized(uint160 sqrtPriceX96) public {
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
key.toId(),
address(modifyLiquidityRouter),
LIQUIDITY_PARAMS.tickLower,
LIQUIDITY_PARAMS.tickUpper,
LIQUIDITY_PARAMS.liquidityDelta
LIQUIDITY_PARAMS.liquidityDelta,
LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity(key, LIQUIDITY_PARAMS, ZERO_BYTES);
Expand All @@ -114,13 +120,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
function test_removeLiquidity_succeedsIfInitialized(uint160 sqrtPriceX96) public {
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
key.toId(),
address(modifyLiquidityRouter),
REMOVE_LIQUIDITY_PARAMS.tickLower,
REMOVE_LIQUIDITY_PARAMS.tickUpper,
REMOVE_LIQUIDITY_PARAMS.liquidityDelta
REMOVE_LIQUIDITY_PARAMS.liquidityDelta,
LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity(key, REMOVE_LIQUIDITY_PARAMS, ZERO_BYTES);
Expand All @@ -129,13 +136,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
function test_addLiquidity_succeedsForNativeTokensIfInitialized(uint160 sqrtPriceX96) public {
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
nativeKey.toId(),
address(modifyLiquidityRouter),
LIQUIDITY_PARAMS.tickLower,
LIQUIDITY_PARAMS.tickUpper,
LIQUIDITY_PARAMS.liquidityDelta
LIQUIDITY_PARAMS.liquidityDelta,
LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity{value: 1 ether}(nativeKey, LIQUIDITY_PARAMS, ZERO_BYTES);
Expand All @@ -144,13 +152,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
function test_removeLiquidity_succeedsForNativeTokensIfInitialized(uint160 sqrtPriceX96) public {
sqrtPriceX96 = uint160(bound(sqrtPriceX96, TickMath.MIN_SQRT_PRICE, TickMath.MAX_SQRT_PRICE - 1));

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
nativeKey.toId(),
address(modifyLiquidityRouter),
REMOVE_LIQUIDITY_PARAMS.tickLower,
REMOVE_LIQUIDITY_PARAMS.tickUpper,
REMOVE_LIQUIDITY_PARAMS.liquidityDelta
REMOVE_LIQUIDITY_PARAMS.liquidityDelta,
LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity{value: 1 ether}(nativeKey, REMOVE_LIQUIDITY_PARAMS, ZERO_BYTES);
Expand Down Expand Up @@ -271,13 +280,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
mockHooks.setReturnValue(mockHooks.beforeAddLiquidity.selector, mockHooks.beforeAddLiquidity.selector);
mockHooks.setReturnValue(mockHooks.afterAddLiquidity.selector, mockHooks.afterAddLiquidity.selector);

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
key.toId(),
address(modifyLiquidityRouter),
LIQUIDITY_PARAMS.tickLower,
LIQUIDITY_PARAMS.tickUpper,
LIQUIDITY_PARAMS.liquidityDelta
LIQUIDITY_PARAMS.liquidityDelta,
LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity(key, LIQUIDITY_PARAMS, ZERO_BYTES);
Expand All @@ -296,13 +306,14 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
mockHooks.setReturnValue(mockHooks.beforeRemoveLiquidity.selector, mockHooks.beforeRemoveLiquidity.selector);
mockHooks.setReturnValue(mockHooks.afterRemoveLiquidity.selector, mockHooks.afterRemoveLiquidity.selector);

vm.expectEmit(true, true, true, true);
vm.expectEmit(true, true, false, true, address(manager));
emit ModifyLiquidity(
key.toId(),
address(modifyLiquidityRouter),
REMOVE_LIQUIDITY_PARAMS.tickLower,
REMOVE_LIQUIDITY_PARAMS.tickUpper,
REMOVE_LIQUIDITY_PARAMS.liquidityDelta
REMOVE_LIQUIDITY_PARAMS.liquidityDelta,
REMOVE_LIQUIDITY_PARAMS.salt
);

modifyLiquidityRouter.modifyLiquidity(key, REMOVE_LIQUIDITY_PARAMS, ZERO_BYTES);
Expand Down
Loading