diff --git a/src/base/Notifier.sol b/src/base/Notifier.sol index 5e56c384d..318e5dadf 100644 --- a/src/base/Notifier.sol +++ b/src/base/Notifier.sol @@ -68,6 +68,7 @@ abstract contract Notifier is INotifier { { _positionConfigs(tokenId).setUnsubscribe(); ISubscriber _subscriber = subscriber[tokenId]; + if (_subscriber == NO_SUBSCRIBER) revert NotSubscribed(); delete subscriber[tokenId]; diff --git a/src/interfaces/INotifier.sol b/src/interfaces/INotifier.sol index 64f734309..49ecddea9 100644 --- a/src/interfaces/INotifier.sol +++ b/src/interfaces/INotifier.sol @@ -6,6 +6,8 @@ import {ISubscriber} from "./ISubscriber.sol"; /// @notice This interface is used to opt in to sending updates to external contracts about position modifications or transfers interface INotifier { + /// @notice Thrown when unsubscribing without a subscriber + error NotSubscribed(); /// @notice Wraps the revert message of the subscriber contract on a reverting subscription error Wrap__SubsciptionReverted(address subscriber, bytes reason); /// @notice Wraps the revert message of the subscriber contract on a reverting modify liquidity notification diff --git a/test/position-managers/PositionManager.notifier.t.sol b/test/position-managers/PositionManager.notifier.t.sol index 9a5dca4d4..82be5f3d9 100644 --- a/test/position-managers/PositionManager.notifier.t.sol +++ b/test/position-managers/PositionManager.notifier.t.sol @@ -340,7 +340,7 @@ contract PositionManagerNotifierTest is Test, PosmTestSetup, GasSnapshot { lpm.approve(address(this), tokenId); vm.stopPrank(); - vm.expectRevert(); + vm.expectRevert(INotifier.NotSubscribed.selector); lpm.unsubscribe(tokenId, config, ZERO_BYTES); }