From f9cf32b5ac66a21150dcabe5157775dad0b241df Mon Sep 17 00:00:00 2001 From: saucepoint <98790946+saucepoint@users.noreply.github.com> Date: Wed, 4 Sep 2024 13:21:17 -0400 Subject: [PATCH] adhere to CEI when unsubscribing on burn (#333) --- .forge-snapshots/PositionManager_burn_empty.snap | 2 +- .forge-snapshots/PositionManager_burn_empty_native.snap | 2 +- .../PositionManager_burn_nonEmpty_native_withClose.snap | 2 +- .../PositionManager_burn_nonEmpty_native_withTakePair.snap | 2 +- .forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap | 2 +- .../PositionManager_burn_nonEmpty_withTakePair.snap | 2 +- .forge-snapshots/PositionManager_decrease_burnEmpty.snap | 2 +- .../PositionManager_decrease_burnEmpty_native.snap | 2 +- src/PositionManager.sol | 4 +++- 9 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.forge-snapshots/PositionManager_burn_empty.snap b/.forge-snapshots/PositionManager_burn_empty.snap index 9301ad1e7..0505afc4b 100644 --- a/.forge-snapshots/PositionManager_burn_empty.snap +++ b/.forge-snapshots/PositionManager_burn_empty.snap @@ -1 +1 @@ -47320 \ No newline at end of file +47276 \ 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 b05cde238..edc2416be 100644 --- a/.forge-snapshots/PositionManager_burn_empty_native.snap +++ b/.forge-snapshots/PositionManager_burn_empty_native.snap @@ -1 +1 @@ -47137 \ No newline at end of file +47094 \ 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 34847302b..2d76ace08 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withClose.snap @@ -1 +1 @@ -123966 \ No newline at end of file +123923 \ 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 f276f26e0..1263d1181 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_native_withTakePair.snap @@ -1 +1 @@ -123464 \ No newline at end of file +123420 \ 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 70b580981..618bac703 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_withClose.snap @@ -1 +1 @@ -131044 \ No newline at end of file +131001 \ 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 acd47ea9c..5a059d8b3 100644 --- a/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap +++ b/.forge-snapshots/PositionManager_burn_nonEmpty_withTakePair.snap @@ -1 +1 @@ -130542 \ No newline at end of file +130499 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap index cd7fd0616..dc105d6a6 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap @@ -1 +1 @@ -135120 \ No newline at end of file +135076 \ 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 1255f67c4..784739a55 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap @@ -1 +1 @@ -127859 \ No newline at end of file +127816 \ No newline at end of file diff --git a/src/PositionManager.sol b/src/PositionManager.sol index 123c51973..9c1533479 100644 --- a/src/PositionManager.sol +++ b/src/PositionManager.sol @@ -335,11 +335,13 @@ contract PositionManager is (liquidityDelta - feesAccrued).validateMinOut(amount0Min, amount1Min); } - if (positionConfigs[tokenId].hasSubscriber()) _unsubscribe(tokenId, config); + bool hasSubscriber = positionConfigs[tokenId].hasSubscriber(); delete positionConfigs[tokenId]; // Burn the token. _burn(tokenId); + + if (hasSubscriber) _unsubscribe(tokenId, config); } function _settlePair(Currency currency0, Currency currency1) internal {