From 21ae9012b830baf85396fa2b643c3dd60c14c044 Mon Sep 17 00:00:00 2001 From: Sara Reynolds Date: Thu, 29 Aug 2024 19:32:58 -0400 Subject: [PATCH] pr commmeeennnnttsss --- .forge-snapshots/PositionManager_burn_empty.snap | 2 +- .../PositionManager_burn_empty_native.snap | 2 +- ...tionManager_burn_nonEmpty_native_withClose.snap | 2 +- ...nManager_burn_nonEmpty_native_withTakePair.snap | 2 +- .../PositionManager_burn_nonEmpty_withClose.snap | 2 +- ...PositionManager_burn_nonEmpty_withTakePair.snap | 2 +- .../PositionManager_collect_native.snap | 2 +- .../PositionManager_collect_sameRange.snap | 2 +- .../PositionManager_collect_withClose.snap | 2 +- .../PositionManager_collect_withTakePair.snap | 2 +- .../PositionManager_decreaseLiquidity_native.snap | 2 +- ...ositionManager_decreaseLiquidity_withClose.snap | 2 +- ...tionManager_decreaseLiquidity_withTakePair.snap | 2 +- .../PositionManager_decrease_burnEmpty.snap | 2 +- .../PositionManager_decrease_burnEmpty_native.snap | 2 +- ...ionManager_decrease_sameRange_allLiquidity.snap | 2 +- .../PositionManager_decrease_take_take.snap | 2 +- ...nManager_increaseLiquidity_erc20_withClose.snap | 2 +- ...ger_increaseLiquidity_erc20_withSettlePair.snap | 2 +- .../PositionManager_increaseLiquidity_native.snap | 2 +- ...er_increase_autocompoundExactUnclaimedFees.snap | 2 +- ...ager_increase_autocompoundExcessFeesCredit.snap | 2 +- ...nManager_increase_autocompound_clearExcess.snap | 2 +- src/PositionManager.sol | 14 +++++++------- src/base/Notifier.sol | 8 ++++---- src/interfaces/IPositionManager.sol | 2 +- src/libraries/PositionInfoLibrary.sol | 1 + test/libraries/PositionInfoLibrary.t.sol | 4 ++-- test/mocks/MockCalldataDecoder.sol | 3 ++- 29 files changed, 40 insertions(+), 38 deletions(-) diff --git a/.forge-snapshots/PositionManager_burn_empty.snap b/.forge-snapshots/PositionManager_burn_empty.snap index 103f8cbee..a958c1a85 100644 --- a/.forge-snapshots/PositionManager_burn_empty.snap +++ b/.forge-snapshots/PositionManager_burn_empty.snap @@ -1 +1 @@ -49954 \ No newline at end of file +49976 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_burn_empty_native.snap b/.forge-snapshots/PositionManager_burn_empty_native.snap index 103f8cbee..a958c1a85 100644 --- a/.forge-snapshots/PositionManager_burn_empty_native.snap +++ b/.forge-snapshots/PositionManager_burn_empty_native.snap @@ -1 +1 @@ -49954 \ No newline at end of file +49976 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap index 4a524dd81..6f2f03083 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap @@ -1 +1 @@ -126207 \ No newline at end of file +126229 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap index 2e228131e..63438b6bf 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap @@ -1 +1 @@ -125704 \ No newline at end of file +125727 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap b/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap index b11d0da00..108ca145a 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap @@ -1 +1 @@ -133103 \ No newline at end of file +133125 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap b/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap index bb2d92b47..f2db0b443 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap @@ -1 +1 @@ -132600 \ No newline at end of file +132623 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_native.snap b/.forge-snapshots/PositionManager_collect_native.snap index 21cc20540..47dc9bae6 100644 --- a/.forge-snapshots/PositionManager_collect_native.snap +++ b/.forge-snapshots/PositionManager_collect_native.snap @@ -1 +1 @@ -146341 \ No newline at end of file +146373 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_sameRange.snap b/.forge-snapshots/PositionManager_collect_sameRange.snap index a6bdd7250..ed7f314c9 100644 --- a/.forge-snapshots/PositionManager_collect_sameRange.snap +++ b/.forge-snapshots/PositionManager_collect_sameRange.snap @@ -1 +1 @@ -154961 \ No newline at end of file +154993 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_withClose.snap b/.forge-snapshots/PositionManager_collect_withClose.snap index a6bdd7250..ed7f314c9 100644 --- a/.forge-snapshots/PositionManager_collect_withClose.snap +++ b/.forge-snapshots/PositionManager_collect_withClose.snap @@ -1 +1 @@ -154961 \ No newline at end of file +154993 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_withTakePair.snap b/.forge-snapshots/PositionManager_collect_withTakePair.snap index a96db4e2b..a547f8b8d 100644 --- a/.forge-snapshots/PositionManager_collect_withTakePair.snap +++ b/.forge-snapshots/PositionManager_collect_withTakePair.snap @@ -1 +1 @@ -154345 \ No newline at end of file +154377 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap index 8550686dc..b331d487f 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap @@ -1 +1 @@ -112548 \ No newline at end of file +112573 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap index ed71e09b7..6f87f5ee2 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap @@ -1 +1 @@ -120504 \ No newline at end of file +120536 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap index 3bb7829f7..4393c1d91 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap @@ -1 +1 @@ -119888 \ No newline at end of file +119920 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap index 2621d201d..288e67b86 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap @@ -1 +1 @@ -135944 \ No newline at end of file +135992 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap b/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap index c543dd683..85e7974ca 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap @@ -1 +1 @@ -129048 \ No newline at end of file +129096 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap b/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap index 02a21f0e3..7833004c4 100644 --- a/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap +++ b/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap @@ -1 +1 @@ -133220 \ No newline at end of file +133252 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_take_take.snap b/.forge-snapshots/PositionManager_decrease_take_take.snap index 09b8ea95e..eef2a0204 100644 --- a/.forge-snapshots/PositionManager_decrease_take_take.snap +++ b/.forge-snapshots/PositionManager_decrease_take_take.snap @@ -1 +1 @@ -121037 \ No newline at end of file +121069 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap index 0048705c8..f35a8a75f 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap @@ -1 +1 @@ -159211 \ No newline at end of file +159243 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap index 5438704ab..000a55b24 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap @@ -1 +1 @@ -158237 \ No newline at end of file +158269 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_native.snap b/.forge-snapshots/PositionManager_increaseLiquidity_native.snap index 1cbfad85b..e165e9044 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_native.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_native.snap @@ -1 +1 @@ -141239 \ No newline at end of file +141271 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap b/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap index 262480fdc..780e30b5b 100644 --- a/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap +++ b/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap @@ -1 +1 @@ -137356 \ No newline at end of file +137388 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap b/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap index d22c381d6..4c54d87d3 100644 --- a/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap +++ b/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap @@ -1 +1 @@ -178272 \ No newline at end of file +178304 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap b/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap index b2ad3c815..28022cc91 100644 --- a/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap +++ b/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap @@ -1 +1 @@ -148228 \ No newline at end of file +148260 \ No newline at end of file diff --git a/src/PositionManager.sol b/src/PositionManager.sol index 279d000fb..6849f61f4 100644 --- a/src/PositionManager.sol +++ b/src/PositionManager.sol @@ -232,7 +232,7 @@ contract PositionManager is uint128 amount1Max, bytes calldata hookData ) internal onlyIfApproved(msgSender(), tokenId) { - (PositionInfo info, PoolKey memory poolKey) = getPoolAndPositionInfo(tokenId); + (PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId); // Note: The tokenId is used as the salt for this position, so every minted position has unique storage in the pool manager. (BalanceDelta liquidityDelta, BalanceDelta feesAccrued) = @@ -249,7 +249,7 @@ contract PositionManager is uint128 amount1Min, bytes calldata hookData ) internal onlyIfApproved(msgSender(), tokenId) { - (PositionInfo info, PoolKey memory poolKey) = getPoolAndPositionInfo(tokenId); + (PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId); // Note: the tokenId is used as the salt. (BalanceDelta liquidityDelta, BalanceDelta feesAccrued) = @@ -298,7 +298,7 @@ contract PositionManager is internal onlyIfApproved(msgSender(), tokenId) { - (PositionInfo info, PoolKey memory poolKey) = getPoolAndPositionInfo(tokenId); + (PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId); uint256 liquidity = uint256(_getLiquidity(tokenId, poolKey, info.tickLower(), info.tickUpper())); @@ -396,12 +396,12 @@ contract PositionManager is } /// @notice an internal helper used by Notifier - function _setSubscribe(uint256 tokenId) internal override { + function _setSubscribed(uint256 tokenId) internal override { positionInfo[tokenId] = positionInfo[tokenId].setSubscribe(); } /// @notice an internal helper used by Notifier - function _setUnsubscribe(uint256 tokenId) internal override { + function _setUnsubscribed(uint256 tokenId) internal override { positionInfo[tokenId] = positionInfo[tokenId].setUnsubscribe(); } @@ -412,14 +412,14 @@ contract PositionManager is } /// @inheritdoc IPositionManager - function getPoolAndPositionInfo(uint256 tokenId) public view returns (PositionInfo info, PoolKey memory poolKey) { + function getPoolAndPositionInfo(uint256 tokenId) public view returns (PoolKey memory poolKey, PositionInfo info) { info = positionInfo[tokenId]; poolKey = poolKeys[info.poolId()]; } /// @inheritdoc IPositionManager function getPositionLiquidity(uint256 tokenId) external view returns (uint128 liquidity) { - (PositionInfo info, PoolKey memory poolKey) = getPoolAndPositionInfo(tokenId); + (PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId); liquidity = _getLiquidity(tokenId, poolKey, info.tickLower(), info.tickUpper()); } diff --git a/src/base/Notifier.sol b/src/base/Notifier.sol index 7ce5ed93f..144d71814 100644 --- a/src/base/Notifier.sol +++ b/src/base/Notifier.sol @@ -31,9 +31,9 @@ abstract contract Notifier is INotifier { modifier onlyIfApproved(address caller, uint256 tokenId) virtual; - function _setUnsubscribe(uint256 tokenId) internal virtual; + function _setUnsubscribed(uint256 tokenId) internal virtual; - function _setSubscribe(uint256 tokenId) internal virtual; + function _setSubscribed(uint256 tokenId) internal virtual; /// @inheritdoc INotifier function subscribe(uint256 tokenId, address newSubscriber, bytes calldata data) @@ -45,7 +45,7 @@ abstract contract Notifier is INotifier { if (_subscriber != NO_SUBSCRIBER) revert AlreadySubscribed(address(_subscriber)); - _setSubscribe(tokenId); + _setSubscribed(tokenId); subscriber[tokenId] = ISubscriber(newSubscriber); bool success = _call(address(newSubscriber), abi.encodeCall(ISubscriber.notifySubscribe, (tokenId, data))); @@ -62,7 +62,7 @@ abstract contract Notifier is INotifier { ISubscriber _subscriber = subscriber[tokenId]; if (_subscriber == NO_SUBSCRIBER) revert AlreadyUnsubscribed(); - _setUnsubscribe(tokenId); + _setUnsubscribed(tokenId); delete subscriber[tokenId]; diff --git a/src/interfaces/IPositionManager.sol b/src/interfaces/IPositionManager.sol index 13cd95b93..46e4f6232 100644 --- a/src/interfaces/IPositionManager.sol +++ b/src/interfaces/IPositionManager.sol @@ -34,5 +34,5 @@ interface IPositionManager is INotifier { /// @param tokenId the ERC721 tokenId /// @return PositionInfo a uint256 packed value holding information about the position including the range (tickLower, tickUpper) /// @return poolKey the pool key of the position - function getPoolAndPositionInfo(uint256 tokenId) external view returns (PositionInfo, PoolKey memory); + function getPoolAndPositionInfo(uint256 tokenId) external view returns (PoolKey memory, PositionInfo); } diff --git a/src/libraries/PositionInfoLibrary.sol b/src/libraries/PositionInfoLibrary.sol index 24dbe367c..981500559 100644 --- a/src/libraries/PositionInfoLibrary.sol +++ b/src/libraries/PositionInfoLibrary.sol @@ -43,6 +43,7 @@ library PositionInfoLibrary { uint8 internal constant TICK_LOWER_OFFSET = 8; uint8 internal constant TICK_UPPER_OFFSET = 32; + /// @dev This poolId is NOT compatible with the poolId used in UniswapV4 core. It is truncated to 25 bytes, and just used to lookup PoolKey in the poolKeys mapping. function poolId(PositionInfo info) internal pure returns (bytes25 _poolId) { assembly ("memory-safe") { _poolId := and(MASK_UPPER_200_BITS, info) diff --git a/test/libraries/PositionInfoLibrary.t.sol b/test/libraries/PositionInfoLibrary.t.sol index 451f6e135..12af50151 100644 --- a/test/libraries/PositionInfoLibrary.t.sol +++ b/test/libraries/PositionInfoLibrary.t.sol @@ -21,7 +21,7 @@ contract PositionInfoLibraryTest is Test { assertEq(info.hasSubscriber(), false); } - function test_fuzz_initialize_setSubscribe(PoolKey memory poolKey, int24 tickLower, int24 tickUpper) public pure { + function test_fuzz_initialize_setSubscribed(PoolKey memory poolKey, int24 tickLower, int24 tickUpper) public pure { PositionInfo info = PositionInfoLibrary.initialize(poolKey, tickLower, tickUpper); assertEq(info.hasSubscriber(), false); info = info.setSubscribe(); @@ -31,7 +31,7 @@ contract PositionInfoLibraryTest is Test { assertEq(info.poolId(), bytes25(PoolId.unwrap(poolKey.toId()))); } - function test_fuzz_initialize_setUnsubscribe(PoolKey memory poolKey, int24 tickLower, int24 tickUpper) + function test_fuzz_initialize_setUnsubscribed(PoolKey memory poolKey, int24 tickLower, int24 tickUpper) public pure { diff --git a/test/mocks/MockCalldataDecoder.sol b/test/mocks/MockCalldataDecoder.sol index 2fbf7afe6..e503e4b0c 100644 --- a/test/mocks/MockCalldataDecoder.sol +++ b/test/mocks/MockCalldataDecoder.sol @@ -9,7 +9,8 @@ import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol"; // we need to use a mock contract to make the calls happen in calldata not memory contract MockCalldataDecoder { using CalldataDecoder for bytes; - + + // This is used to avoid compiling with via-ir. struct MintParams { PoolKey poolKey; int24 tickLower;