Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use solmate owned #520

Merged
merged 7 commits into from
Mar 28, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 @@
265799
265795
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 @@
140642
140638
2 changes: 1 addition & 1 deletion .forge-snapshots/addLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
145959
145955
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 1 token.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
101654
101564
2 changes: 1 addition & 1 deletion .forge-snapshots/donate gas with 2 tokens.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
128667
128619
2 changes: 1 addition & 1 deletion .forge-snapshots/erc20 collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
24938
24961
2 changes: 1 addition & 1 deletion .forge-snapshots/initialize.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
51819
51797
2 changes: 1 addition & 1 deletion .forge-snapshots/native collect protocol fees.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
36611
36634
2 changes: 1 addition & 1 deletion .forge-snapshots/poolManager bytecode size.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
23026
23071
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 @@
56574
56486
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 @@
148760
148672
2 changes: 1 addition & 1 deletion .forge-snapshots/removeLiquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
150224
150136
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap with native.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
133409
133341
2 changes: 1 addition & 1 deletion .forge-snapshots/simple swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
147285
147217
Original file line number Diff line number Diff line change
@@ -1 +1 @@
72868
72800
2 changes: 1 addition & 1 deletion .forge-snapshots/swap against liquidity.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60871
60803
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
80985
80875
2 changes: 1 addition & 1 deletion .forge-snapshots/swap burn native 6909 for input.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
76940
76830
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint native output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
139268
139223
2 changes: 1 addition & 1 deletion .forge-snapshots/swap mint output as 6909.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
156077
156032
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with dynamic fee.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
90176
90108
2 changes: 1 addition & 1 deletion .forge-snapshots/swap with hooks.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
60849
60781
2 changes: 1 addition & 1 deletion .forge-snapshots/update dynamic fee in before swap.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
141181
141091
29 changes: 0 additions & 29 deletions src/Owned.sol

This file was deleted.

1 change: 0 additions & 1 deletion src/PoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down
4 changes: 2 additions & 2 deletions src/ProtocolFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
}

Expand Down
2 changes: 2 additions & 0 deletions src/interfaces/IProtocolFees.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down
43 changes: 0 additions & 43 deletions test/Owned.t.sol

This file was deleted.

15 changes: 12 additions & 3 deletions test/PoolManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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";
Expand Down Expand Up @@ -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));
Expand All @@ -78,6 +77,16 @@ contract PoolManagerTest is Test, Deployers, GasSnapshot {
assertEq(address(manager.protocolFeeController()), address(feeController));
}

function test_setProtocolFeeController_failsIfNotOwner() public {
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

technically i think this will be moved out of this file (like a lot of other tests tbh) but since we haven't migrated the tests out of here I think its fine for this PR. and whoever is assigned with ProtocolFees.t.sol will move it (I think its me so I can do it when I pick that up).

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);
Expand Down Expand Up @@ -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);
}

Expand Down
Loading