Skip to content

Commit

Permalink
add salt to modLiq event (Uniswap#818)
Browse files Browse the repository at this point in the history
* add salt to modLiq event

* natspec
  • Loading branch information
snreynolds authored Aug 5, 2024
1 parent d3be002 commit e37e010
Show file tree
Hide file tree
Showing 16 changed files with 40 additions and 28 deletions.
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
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

0 comments on commit e37e010

Please sign in to comment.