diff --git a/.forge-snapshots/addLiquidity with empty hook.snap b/.forge-snapshots/addLiquidity with empty hook.snap index e2bd4e7ac..a5c8b7976 100644 --- a/.forge-snapshots/addLiquidity with empty hook.snap +++ b/.forge-snapshots/addLiquidity with empty hook.snap @@ -1 +1 @@ -265799 \ No newline at end of file +265795 \ No newline at end of file diff --git a/.forge-snapshots/addLiquidity with native token.snap b/.forge-snapshots/addLiquidity with native token.snap index 2e5687233..bbd4c5e60 100644 --- a/.forge-snapshots/addLiquidity with native token.snap +++ b/.forge-snapshots/addLiquidity with native token.snap @@ -1 +1 @@ -140642 \ No newline at end of file +140638 \ No newline at end of file diff --git a/.forge-snapshots/addLiquidity.snap b/.forge-snapshots/addLiquidity.snap index b36da47c1..bf6bedbf8 100644 --- a/.forge-snapshots/addLiquidity.snap +++ b/.forge-snapshots/addLiquidity.snap @@ -1 +1 @@ -145959 \ No newline at end of file +145955 \ No newline at end of file diff --git a/.forge-snapshots/donate gas with 1 token.snap b/.forge-snapshots/donate gas with 1 token.snap index 3829a9cc6..174ef3d97 100644 --- a/.forge-snapshots/donate gas with 1 token.snap +++ b/.forge-snapshots/donate gas with 1 token.snap @@ -1 +1 @@ -101654 \ No newline at end of file +101564 \ No newline at end of file diff --git a/.forge-snapshots/donate gas with 2 tokens.snap b/.forge-snapshots/donate gas with 2 tokens.snap index f59cb30b4..1f2f552d1 100644 --- a/.forge-snapshots/donate gas with 2 tokens.snap +++ b/.forge-snapshots/donate gas with 2 tokens.snap @@ -1 +1 @@ -128667 \ No newline at end of file +128619 \ No newline at end of file diff --git a/.forge-snapshots/erc20 collect protocol fees.snap b/.forge-snapshots/erc20 collect protocol fees.snap index 36cf22341..b9fe27a3f 100644 --- a/.forge-snapshots/erc20 collect protocol fees.snap +++ b/.forge-snapshots/erc20 collect protocol fees.snap @@ -1 +1 @@ -24938 \ No newline at end of file +24961 \ No newline at end of file diff --git a/.forge-snapshots/initialize.snap b/.forge-snapshots/initialize.snap index df1ae0e82..56805387d 100644 --- a/.forge-snapshots/initialize.snap +++ b/.forge-snapshots/initialize.snap @@ -1 +1 @@ -51819 \ No newline at end of file +51797 \ No newline at end of file diff --git a/.forge-snapshots/native collect protocol fees.snap b/.forge-snapshots/native collect protocol fees.snap index 5d4c1b5c0..984502b79 100644 --- a/.forge-snapshots/native collect protocol fees.snap +++ b/.forge-snapshots/native collect protocol fees.snap @@ -1 +1 @@ -36611 \ No newline at end of file +36634 \ No newline at end of file diff --git a/.forge-snapshots/poolManager bytecode size.snap b/.forge-snapshots/poolManager bytecode size.snap index 3cf278ca1..6c49d3b64 100644 --- a/.forge-snapshots/poolManager bytecode size.snap +++ b/.forge-snapshots/poolManager bytecode size.snap @@ -1 +1 @@ -23026 \ No newline at end of file +23071 \ No newline at end of file diff --git a/.forge-snapshots/removeLiquidity with empty hook.snap b/.forge-snapshots/removeLiquidity with empty hook.snap index 8c729b8ed..7f8f52f0d 100644 --- a/.forge-snapshots/removeLiquidity with empty hook.snap +++ b/.forge-snapshots/removeLiquidity with empty hook.snap @@ -1 +1 @@ -56574 \ No newline at end of file +56486 \ No newline at end of file diff --git a/.forge-snapshots/removeLiquidity with native token.snap b/.forge-snapshots/removeLiquidity with native token.snap index ab62f35c6..8251926b6 100644 --- a/.forge-snapshots/removeLiquidity with native token.snap +++ b/.forge-snapshots/removeLiquidity with native token.snap @@ -1 +1 @@ -148760 \ No newline at end of file +148672 \ No newline at end of file diff --git a/.forge-snapshots/removeLiquidity.snap b/.forge-snapshots/removeLiquidity.snap index 24c0b40b7..4f0ad04f6 100644 --- a/.forge-snapshots/removeLiquidity.snap +++ b/.forge-snapshots/removeLiquidity.snap @@ -1 +1 @@ -150224 \ No newline at end of file +150136 \ No newline at end of file diff --git a/.forge-snapshots/simple swap with native.snap b/.forge-snapshots/simple swap with native.snap index df22d79b2..bd76bf91b 100644 --- a/.forge-snapshots/simple swap with native.snap +++ b/.forge-snapshots/simple swap with native.snap @@ -1 +1 @@ -133409 \ No newline at end of file +133341 \ No newline at end of file diff --git a/.forge-snapshots/simple swap.snap b/.forge-snapshots/simple swap.snap index ba806de9b..360f528c3 100644 --- a/.forge-snapshots/simple swap.snap +++ b/.forge-snapshots/simple swap.snap @@ -1 +1 @@ -147285 \ No newline at end of file +147217 \ No newline at end of file diff --git a/.forge-snapshots/swap against liquidity with native token.snap b/.forge-snapshots/swap against liquidity with native token.snap index addfbca9d..f03dcc1dc 100644 --- a/.forge-snapshots/swap against liquidity with native token.snap +++ b/.forge-snapshots/swap against liquidity with native token.snap @@ -1 +1 @@ -72868 \ No newline at end of file +72800 \ No newline at end of file diff --git a/.forge-snapshots/swap against liquidity.snap b/.forge-snapshots/swap against liquidity.snap index 386cc244e..6fa3193ed 100644 --- a/.forge-snapshots/swap against liquidity.snap +++ b/.forge-snapshots/swap against liquidity.snap @@ -1 +1 @@ -60871 \ No newline at end of file +60803 \ No newline at end of file diff --git a/.forge-snapshots/swap burn 6909 for input.snap b/.forge-snapshots/swap burn 6909 for input.snap index 0061a05c6..84c55f1aa 100644 --- a/.forge-snapshots/swap burn 6909 for input.snap +++ b/.forge-snapshots/swap burn 6909 for input.snap @@ -1 +1 @@ -80985 \ No newline at end of file +80875 \ No newline at end of file diff --git a/.forge-snapshots/swap burn native 6909 for input.snap b/.forge-snapshots/swap burn native 6909 for input.snap index ab62c1cbb..953cdd6da 100644 --- a/.forge-snapshots/swap burn native 6909 for input.snap +++ b/.forge-snapshots/swap burn native 6909 for input.snap @@ -1 +1 @@ -76940 \ No newline at end of file +76830 \ No newline at end of file diff --git a/.forge-snapshots/swap mint native output as 6909.snap b/.forge-snapshots/swap mint native output as 6909.snap index 566df1219..ad7bf33b6 100644 --- a/.forge-snapshots/swap mint native output as 6909.snap +++ b/.forge-snapshots/swap mint native output as 6909.snap @@ -1 +1 @@ -139268 \ No newline at end of file +139223 \ No newline at end of file diff --git a/.forge-snapshots/swap mint output as 6909.snap b/.forge-snapshots/swap mint output as 6909.snap index 982481321..809e04d35 100644 --- a/.forge-snapshots/swap mint output as 6909.snap +++ b/.forge-snapshots/swap mint output as 6909.snap @@ -1 +1 @@ -156077 \ No newline at end of file +156032 \ No newline at end of file diff --git a/.forge-snapshots/swap with dynamic fee.snap b/.forge-snapshots/swap with dynamic fee.snap index b978e8a3e..acc92877f 100644 --- a/.forge-snapshots/swap with dynamic fee.snap +++ b/.forge-snapshots/swap with dynamic fee.snap @@ -1 +1 @@ -90176 \ No newline at end of file +90108 \ No newline at end of file diff --git a/.forge-snapshots/swap with hooks.snap b/.forge-snapshots/swap with hooks.snap index 160b64063..d9ad4853c 100644 --- a/.forge-snapshots/swap with hooks.snap +++ b/.forge-snapshots/swap with hooks.snap @@ -1 +1 @@ -60849 \ No newline at end of file +60781 \ No newline at end of file diff --git a/.forge-snapshots/update dynamic fee in before swap.snap b/.forge-snapshots/update dynamic fee in before swap.snap index 98aa37ccb..b362d08e8 100644 --- a/.forge-snapshots/update dynamic fee in before swap.snap +++ b/.forge-snapshots/update dynamic fee in before swap.snap @@ -1 +1 @@ -141181 \ No newline at end of file +141091 \ No newline at end of file diff --git a/src/Owned.sol b/src/Owned.sol deleted file mode 100644 index 7f31fbab8..000000000 --- a/src/Owned.sol +++ /dev/null @@ -1,29 +0,0 @@ -// SPDX-License-Identifier: BUSL-1.1 -pragma solidity ^0.8.20; - -contract Owned { - address public owner; - bytes12 private STORAGE_PLACEHOLDER; - - error InvalidCaller(); - - /// @notice Emitted when the owner of the factory is changed - /// @param oldOwner The owner before the owner was changed - /// @param newOwner The owner after the owner was changed - event OwnerChanged(address indexed oldOwner, address indexed newOwner); - - modifier onlyOwner() { - if (msg.sender != owner) revert InvalidCaller(); - _; - } - - constructor() { - owner = msg.sender; - emit OwnerChanged(address(0), msg.sender); - } - - function setOwner(address _owner) external onlyOwner { - emit OwnerChanged(owner, _owner); - owner = _owner; - } -} diff --git a/src/PoolManager.sol b/src/PoolManager.sol index 0a6fb95df..9f7546dc2 100644 --- a/src/PoolManager.sol +++ b/src/PoolManager.sol @@ -10,7 +10,6 @@ import {Currency, CurrencyLibrary} from "./types/Currency.sol"; import {PoolKey} from "./types/PoolKey.sol"; import {TickMath} from "./libraries/TickMath.sol"; import {NoDelegateCall} from "./NoDelegateCall.sol"; -import {Owned} from "./Owned.sol"; import {IHooks} from "./interfaces/IHooks.sol"; import {IPoolManager} from "./interfaces/IPoolManager.sol"; import {IUnlockCallback} from "./interfaces/callback/IUnlockCallback.sol"; diff --git a/src/ProtocolFees.sol b/src/ProtocolFees.sol index b70ad12b8..7d727b8ab 100644 --- a/src/ProtocolFees.sol +++ b/src/ProtocolFees.sol @@ -6,7 +6,7 @@ import {IProtocolFeeController} from "./interfaces/IProtocolFeeController.sol"; import {IProtocolFees} from "./interfaces/IProtocolFees.sol"; import {Pool} from "./libraries/Pool.sol"; import {PoolKey} from "./types/PoolKey.sol"; -import {Owned} from "./Owned.sol"; +import {Owned} from "solmate/auth/Owned.sol"; abstract contract ProtocolFees is IProtocolFees, Owned { using CurrencyLibrary for Currency; @@ -19,7 +19,7 @@ abstract contract ProtocolFees is IProtocolFees, Owned { uint256 private immutable controllerGasLimit; - constructor(uint256 _controllerGasLimit) { + constructor(uint256 _controllerGasLimit) Owned(msg.sender) { controllerGasLimit = _controllerGasLimit; } diff --git a/src/interfaces/IProtocolFees.sol b/src/interfaces/IProtocolFees.sol index 2113f17b5..943e064ac 100644 --- a/src/interfaces/IProtocolFees.sol +++ b/src/interfaces/IProtocolFees.sol @@ -10,6 +10,8 @@ interface IProtocolFees { error ProtocolFeeControllerCallFailedOrInvalidResult(); /// @notice Thrown when a pool does not have a dynamic fee. error FeeNotDynamic(); + /// @notice Thrown when collectProtocolFees is not called by the controller. + error InvalidCaller(); event ProtocolFeeControllerUpdated(address protocolFeeController); diff --git a/test/Owned.t.sol b/test/Owned.t.sol deleted file mode 100644 index 9bbeda0bf..000000000 --- a/test/Owned.t.sol +++ /dev/null @@ -1,43 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import {Test} from "forge-std/Test.sol"; -import {Vm} from "forge-std/Vm.sol"; -import {Owned} from "../src/Owned.sol"; - -contract OwnedTest is Test { - Owned owned; - - function testConstructor(address owner) public { - deployOwnedWithOwner(owner); - - assertEq(owner, owned.owner()); - } - - function testSetOwnerFromOwner(address oldOwner, address nextOwner) public { - // set the old owner as the owner - deployOwnedWithOwner(oldOwner); - - // old owner passes over ownership - vm.prank(oldOwner); - owned.setOwner(nextOwner); - assertEq(nextOwner, owned.owner()); - } - - function testSetOwnerFromNonOwner(address oldOwner, address nextOwner) public { - // set the old owner as the owner - deployOwnedWithOwner(oldOwner); - - if (oldOwner != nextOwner) { - vm.startPrank(nextOwner); - vm.expectRevert(Owned.InvalidCaller.selector); - owned.setOwner(nextOwner); - vm.stopPrank(); - } - } - - function deployOwnedWithOwner(address owner) internal { - vm.prank(owner); - owned = new Owned(); - } -} diff --git a/test/PoolManager.t.sol b/test/PoolManager.t.sol index d0e2125ad..ef8e67975 100644 --- a/test/PoolManager.t.sol +++ b/test/PoolManager.t.sol @@ -8,7 +8,6 @@ import {IPoolManager} from "../src/interfaces/IPoolManager.sol"; import {IProtocolFees} from "../src/interfaces/IProtocolFees.sol"; import {IProtocolFeeController} from "../src/interfaces/IProtocolFeeController.sol"; import {PoolManager} from "../src/PoolManager.sol"; -import {Owned} from "../src/Owned.sol"; import {TickMath} from "../src/libraries/TickMath.sol"; import {Pool} from "../src/libraries/Pool.sol"; import {Deployers} from "./utils/Deployers.sol"; @@ -69,7 +68,7 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot { snapSize("poolManager bytecode size", address(manager)); } - function test_feeControllerSet() public { + function test_setProtocolFeeController_succeeds() public { deployFreshManager(); assertEq(address(manager.protocolFeeController()), address(0)); vm.expectEmit(false, false, false, true, address(manager)); @@ -78,6 +77,16 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot { assertEq(address(manager.protocolFeeController()), address(feeController)); } + function test_setProtocolFeeController_failsIfNotOwner() public { + deployFreshManager(); + assertEq(address(manager.protocolFeeController()), address(0)); + + vm.prank(address(1)); // not the owner address + vm.expectRevert("UNAUTHORIZED"); + manager.setProtocolFeeController(feeController); + assertEq(address(manager.protocolFeeController()), address(0)); + } + function test_addLiquidity_failsIfNotInitialized() public { vm.expectRevert(Pool.PoolNotInitialized.selector); modifyLiquidityRouter.modifyLiquidity(uninitializedKey, LIQ_PARAMS, ZERO_BYTES); @@ -984,7 +993,7 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot { } function test_collectProtocolFees_revertsIfCallerIsNotController() public { - vm.expectRevert(Owned.InvalidCaller.selector); + vm.expectRevert(IProtocolFees.InvalidCaller.selector); manager.collectProtocolFees(address(1), currency0, 0); }