From 27a8b7680157b081aceb9fd6967c6794d5206903 Mon Sep 17 00:00:00 2001 From: Sara Reynolds Date: Fri, 18 Oct 2024 13:55:49 -0400 Subject: [PATCH] remove IProtocolFeeController --- .../poolManager bytecode size.snap | 2 +- ...wap skips hook call if hook is caller.snap | 2 +- .forge-snapshots/swap with dynamic fee.snap | 2 +- .../swap with lp fee and protocol fee.snap | 2 +- .../swap with return dynamic fee.snap | 2 +- .../update dynamic fee in before swap.snap | 2 +- src/ProtocolFees.sol | 5 ++--- src/interfaces/IPoolManager.sol | 2 +- src/interfaces/IProtocolFeeController.sol | 15 --------------- src/interfaces/IProtocolFees.sol | 7 +++---- src/libraries/Hooks.sol | 2 +- src/libraries/LPFeeLibrary.sol | 2 +- src/test/Fuzzers.sol | 2 +- src/test/ProtocolFeeControllerTest.sol | 19 ------------------- test/CustomAccounting.t.sol | 2 +- test/PoolManager.t.sol | 1 - test/PoolManagerInitialize.t.sol | 2 -- test/ProtocolFeesImplementation.t.sol | 3 +-- test/utils/Deployers.sol | 8 ++++---- 19 files changed, 21 insertions(+), 61 deletions(-) delete mode 100644 src/interfaces/IProtocolFeeController.sol delete mode 100644 src/test/ProtocolFeeControllerTest.sol diff --git a/.forge-snapshots/poolManager bytecode size.snap b/.forge-snapshots/poolManager bytecode size.snap index 37be6af7a..cbe35bf2e 100644 --- a/.forge-snapshots/poolManager bytecode size.snap +++ b/.forge-snapshots/poolManager bytecode size.snap @@ -1 +1 @@ -23621 \ No newline at end of file +23598 \ No newline at end of file diff --git a/.forge-snapshots/swap skips hook call if hook is caller.snap b/.forge-snapshots/swap skips hook call if hook is caller.snap index f1e126934..a98a52ade 100644 --- a/.forge-snapshots/swap skips hook call if hook is caller.snap +++ b/.forge-snapshots/swap skips hook call if hook is caller.snap @@ -1 +1 @@ -206403 \ No newline at end of file +206415 \ 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 feaacc0ab..7e8319d12 100644 --- a/.forge-snapshots/swap with dynamic fee.snap +++ b/.forge-snapshots/swap with dynamic fee.snap @@ -1 +1 @@ -139368 \ No newline at end of file +139356 \ No newline at end of file diff --git a/.forge-snapshots/swap with lp fee and protocol fee.snap b/.forge-snapshots/swap with lp fee and protocol fee.snap index 8c298d1fe..230c98511 100644 --- a/.forge-snapshots/swap with lp fee and protocol fee.snap +++ b/.forge-snapshots/swap with lp fee and protocol fee.snap @@ -1 +1 @@ -169593 \ No newline at end of file +169581 \ No newline at end of file diff --git a/.forge-snapshots/swap with return dynamic fee.snap b/.forge-snapshots/swap with return dynamic fee.snap index bcbae20f7..09bc9151b 100644 --- a/.forge-snapshots/swap with return dynamic fee.snap +++ b/.forge-snapshots/swap with return dynamic fee.snap @@ -1 +1 @@ -145661 \ No newline at end of file +145673 \ 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 8a6f38517..01cd1bdff 100644 --- a/.forge-snapshots/update dynamic fee in before swap.snap +++ b/.forge-snapshots/update dynamic fee in before swap.snap @@ -1 +1 @@ -147956 \ No newline at end of file +147944 \ No newline at end of file diff --git a/src/ProtocolFees.sol b/src/ProtocolFees.sol index ecea47484..e3742a210 100644 --- a/src/ProtocolFees.sol +++ b/src/ProtocolFees.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.0; import {Currency} from "./types/Currency.sol"; -import {IProtocolFeeController} from "./interfaces/IProtocolFeeController.sol"; import {IProtocolFees} from "./interfaces/IProtocolFees.sol"; import {PoolKey} from "./types/PoolKey.sol"; import {ProtocolFeeLibrary} from "./libraries/ProtocolFeeLibrary.sol"; @@ -21,12 +20,12 @@ abstract contract ProtocolFees is IProtocolFees, Owned { mapping(Currency currency => uint256 amount) public protocolFeesAccrued; /// @inheritdoc IProtocolFees - IProtocolFeeController public protocolFeeController; + address public protocolFeeController; constructor() Owned(msg.sender) {} /// @inheritdoc IProtocolFees - function setProtocolFeeController(IProtocolFeeController controller) external onlyOwner { + function setProtocolFeeController(address controller) external onlyOwner { protocolFeeController = controller; emit ProtocolFeeControllerUpdated(address(controller)); } diff --git a/src/interfaces/IPoolManager.sol b/src/interfaces/IPoolManager.sol index 3269851d0..68eb0ab2b 100644 --- a/src/interfaces/IPoolManager.sol +++ b/src/interfaces/IPoolManager.sol @@ -55,7 +55,7 @@ interface IPoolManager is IProtocolFees, IERC6909Claims, IExtsload, IExttload { /// @param tickSpacing The minimum number of ticks between initialized ticks /// @param hooks The hooks contract address for the pool, or address(0) if none /// @param sqrtPriceX96 The price of the pool on initialization - /// @param tick The initial tick of the pool corresponding to the intialized price + /// @param tick The initial tick of the pool corresponding to the initialized price event Initialize( PoolId indexed id, Currency indexed currency0, diff --git a/src/interfaces/IProtocolFeeController.sol b/src/interfaces/IProtocolFeeController.sol deleted file mode 100644 index 44f4f2cf2..000000000 --- a/src/interfaces/IProtocolFeeController.sol +++ /dev/null @@ -1,15 +0,0 @@ -// SPDX-License-Identifier: MIT -pragma solidity ^0.8.0; - -import {PoolKey} from "../types/PoolKey.sol"; - -/// @notice Interface to fetch the protocol fees for a pool from the protocol fee controller -interface IProtocolFeeController { - /// @notice Returns the protocol fees for a pool given the conditions of this contract - /// @param poolKey The pool key to identify the pool. The controller may want to use attributes on the pool - /// to determine the protocol fee, hence the entire key is needed. - /// @return protocolFee The pool's protocol fee, expressed in hundredths of a bip. The upper 12 bits are for 1->0 - /// and the lower 12 are for 0->1. The maximum is 1000 - meaning the maximum protocol fee is 0.1%. - /// the protocolFee is taken from the input first, then the lpFee is taken from the remaining input - function protocolFeeForPool(PoolKey memory poolKey) external view returns (uint24 protocolFee); -} diff --git a/src/interfaces/IProtocolFees.sol b/src/interfaces/IProtocolFees.sol index 0717bfc88..8677fa277 100644 --- a/src/interfaces/IProtocolFees.sol +++ b/src/interfaces/IProtocolFees.sol @@ -2,7 +2,6 @@ pragma solidity ^0.8.0; import {Currency} from "../types/Currency.sol"; -import {IProtocolFeeController} from "../interfaces/IProtocolFeeController.sol"; import {PoolId} from "../types/PoolId.sol"; import {PoolKey} from "../types/PoolKey.sol"; @@ -35,7 +34,7 @@ interface IProtocolFees { /// @notice Sets the protocol fee controller /// @param controller The new protocol fee controller - function setProtocolFeeController(IProtocolFeeController controller) external; + function setProtocolFeeController(address controller) external; /// @notice Collects the protocol fees for a given recipient and currency, returning the amount collected /// @dev This will revert if the contract is unlocked @@ -48,6 +47,6 @@ interface IProtocolFees { returns (uint256 amountCollected); /// @notice Returns the current protocol fee controller address - /// @return IProtocolFeeController The currency protocol fee controller - function protocolFeeController() external view returns (IProtocolFeeController); + /// @return address The currenct protocol fee controller address + function protocolFeeController() external view returns (address); } diff --git a/src/libraries/Hooks.sol b/src/libraries/Hooks.sol index 2f02548f5..7c4b4775b 100644 --- a/src/libraries/Hooks.sol +++ b/src/libraries/Hooks.sol @@ -159,7 +159,7 @@ library Hooks { function callHookWithReturnDelta(IHooks self, bytes memory data, bool parseReturn) internal returns (int256) { bytes memory result = callHook(self, data); - // If this hook wasnt meant to return something, default to 0 delta + // If this hook wasn't meant to return something, default to 0 delta if (!parseReturn) return 0; // A length of 64 bytes is required to return a bytes4, and a 32 byte delta diff --git a/src/libraries/LPFeeLibrary.sol b/src/libraries/LPFeeLibrary.sol index a2a732a81..b7e145332 100644 --- a/src/libraries/LPFeeLibrary.sol +++ b/src/libraries/LPFeeLibrary.sol @@ -11,7 +11,7 @@ library LPFeeLibrary { /// @notice Thrown when the static or dynamic fee on a pool exceeds 100%. error LPFeeTooLarge(uint24 fee); - /// @notice An lp fee of exactly 0b1000000... signals a dynamic fee pool. This isnt a valid static fee as it is > MAX_LP_FEE + /// @notice An lp fee of exactly 0b1000000... signals a dynamic fee pool. This isn't a valid static fee as it is > MAX_LP_FEE uint24 public constant DYNAMIC_FEE_FLAG = 0x800000; /// @notice the second bit of the fee returned by beforeSwap is used to signal if the stored LP fee should be overridden in this swap diff --git a/src/test/Fuzzers.sol b/src/test/Fuzzers.sol index eccf55b57..04c2c11bf 100644 --- a/src/test/Fuzzers.sol +++ b/src/test/Fuzzers.sol @@ -142,7 +142,7 @@ contract Fuzzers is StdUtils { result.liquidityDelta = boundLiquidityDelta(key, params.liquidityDelta, liquidityDeltaFromAmounts); } - // Creates liquidity parameters with a stricter bound. Should be used if multiple positions being intitialized on the pool, with potential for tick overlap. + // Creates liquidity parameters with a stricter bound. Should be used if multiple positions being initialized on the pool, with potential for tick overlap. function createFuzzyLiquidityParamsWithTightBound( PoolKey memory key, IPoolManager.ModifyLiquidityParams memory params, diff --git a/src/test/ProtocolFeeControllerTest.sol b/src/test/ProtocolFeeControllerTest.sol deleted file mode 100644 index 25fc0795d..000000000 --- a/src/test/ProtocolFeeControllerTest.sol +++ /dev/null @@ -1,19 +0,0 @@ -// SPDX-License-Identifier: UNLICENSED -pragma solidity ^0.8.20; - -import {IProtocolFeeController} from "../interfaces/IProtocolFeeController.sol"; -import {PoolId} from "../types/PoolId.sol"; -import {PoolKey} from "../types/PoolKey.sol"; - -contract ProtocolFeeControllerTest is IProtocolFeeController { - mapping(PoolId => uint24) public protocolFee; - - function protocolFeeForPool(PoolKey memory key) external view returns (uint24) { - return protocolFee[key.toId()]; - } - - // for tests to set pool protocol fees - function setProtocolFeeForPool(PoolId id, uint24 fee) external { - protocolFee[id] = fee; - } -} diff --git a/test/CustomAccounting.t.sol b/test/CustomAccounting.t.sol index e4942dce3..4a06aed0e 100644 --- a/test/CustomAccounting.t.sol +++ b/test/CustomAccounting.t.sol @@ -254,7 +254,7 @@ contract CustomAccountingTest is Test, Deployers, GasSnapshot { "manager balance change exact input" ); - // exact output, where there isnt enough output reserves available to pay swap and hook + // exact output, where there isn't enough output reserves available to pay swap and hook } else if (!isExactIn && (hookDeltaSpecified + amountSpecified > maxPossibleOut_fuzz_test)) { // the hook will have taken hookDeltaSpecified of the maxPossibleOut assertEq(deltaSpecified, maxPossibleOut_fuzz_test - hookDeltaSpecified, "deltaSpecified exact output"); diff --git a/test/PoolManager.t.sol b/test/PoolManager.t.sol index be71725a1..c755d24f9 100644 --- a/test/PoolManager.t.sol +++ b/test/PoolManager.t.sol @@ -6,7 +6,6 @@ import {IHooks} from "../src/interfaces/IHooks.sol"; import {Hooks} from "../src/libraries/Hooks.sol"; 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 {TickMath} from "../src/libraries/TickMath.sol"; import {Pool} from "../src/libraries/Pool.sol"; diff --git a/test/PoolManagerInitialize.t.sol b/test/PoolManagerInitialize.t.sol index b4c9b43d0..006b37c6c 100644 --- a/test/PoolManagerInitialize.t.sol +++ b/test/PoolManagerInitialize.t.sol @@ -19,8 +19,6 @@ import {PoolKey} from "../src/types/PoolKey.sol"; import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol"; import {PoolId} from "../src/types/PoolId.sol"; import {LPFeeLibrary} from "../src/libraries/LPFeeLibrary.sol"; -import {ProtocolFeeControllerTest} from "../src/test/ProtocolFeeControllerTest.sol"; -import {IProtocolFeeController} from "../src/interfaces/IProtocolFeeController.sol"; import {ProtocolFeeLibrary} from "../src/libraries/ProtocolFeeLibrary.sol"; import {StateLibrary} from "../src/libraries/StateLibrary.sol"; diff --git a/test/ProtocolFeesImplementation.t.sol b/test/ProtocolFeesImplementation.t.sol index f5f7007ea..40beb25b5 100644 --- a/test/ProtocolFeesImplementation.t.sol +++ b/test/ProtocolFeesImplementation.t.sol @@ -14,7 +14,6 @@ import {Deployers} from "../test/utils/Deployers.sol"; import {PoolId} from "../src/types/PoolId.sol"; import {IHooks} from "../src/interfaces/IHooks.sol"; import {Constants} from "../test/utils/Constants.sol"; -import {ProtocolFeeControllerTest} from "../src/test/ProtocolFeeControllerTest.sol"; contract ProtocolFeesTest is Test, GasSnapshot, Deployers { using ProtocolFeeLibrary for uint24; @@ -28,7 +27,7 @@ contract ProtocolFeesTest is Test, GasSnapshot, Deployers { function setUp() public { protocolFees = new ProtocolFeesImplementation(); - feeController = new ProtocolFeeControllerTest(); + feeController = makeAddr("feeController"); (currency0, currency1) = deployAndMint2Currencies(); MockERC20(Currency.unwrap(currency0)).transfer(address(protocolFees), 2 ** 255); } diff --git a/test/utils/Deployers.sol b/test/utils/Deployers.sol index f15b42461..27b179a4c 100644 --- a/test/utils/Deployers.sol +++ b/test/utils/Deployers.sol @@ -1,6 +1,7 @@ // SPDX-License-Identifier: UNLICENSED pragma solidity ^0.8.20; +import "forge-std/Test.sol"; import {MockERC20} from "solmate/src/test/utils/mocks/MockERC20.sol"; import {Hooks} from "../../src/libraries/Hooks.sol"; import {Currency, CurrencyLibrary} from "../../src/types/Currency.sol"; @@ -25,9 +26,8 @@ import {PoolClaimsTest} from "../../src/test/PoolClaimsTest.sol"; import {ActionsRouter} from "../../src/test/ActionsRouter.sol"; import {LiquidityAmounts} from "../../test/utils/LiquidityAmounts.sol"; import {StateLibrary} from "../../src/libraries/StateLibrary.sol"; -import {ProtocolFeeControllerTest} from "../../src/test/ProtocolFeeControllerTest.sol"; -contract Deployers { +contract Deployers is Test { using LPFeeLibrary for uint24; using StateLibrary for IPoolManager; @@ -63,7 +63,7 @@ contract Deployers { PoolClaimsTest claimsRouter; PoolNestedActionsTest nestedActionRouter; - ProtocolFeeControllerTest feeController; + address feeController; PoolKey key; PoolKey nativeKey; @@ -88,7 +88,7 @@ contract Deployers { takeRouter = new PoolTakeTest(manager); claimsRouter = new PoolClaimsTest(manager); nestedActionRouter = new PoolNestedActionsTest(manager); - feeController = new ProtocolFeeControllerTest(); + feeController = makeAddr("feeController"); actionsRouter = new ActionsRouter(manager); manager.setProtocolFeeController(feeController);