diff --git a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap index 87154c04..4e999170 100644 --- a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap @@ -1 +1 @@ -109021 \ No newline at end of file +108896 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap index 5e68eac6..8b42096b 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap @@ -1 +1 @@ -37221 \ No newline at end of file +37096 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap index a118ebd3..cfdb5d7c 100644 --- a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap @@ -1 +1 @@ -36477 \ No newline at end of file +36480 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicSwapFee.snap b/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicSwapFee.snap index 752ba3d3..59641c57 100644 --- a/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicSwapFee.snap +++ b/.forge-snapshots/CLPoolManagerTest#testFuzzUpdateDynamicSwapFee.snap @@ -1 +1 @@ -5496 \ No newline at end of file +5499 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap index 023fdc04..c7a1b790 100644 --- a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap +++ b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap @@ -1 +1 @@ -37427 \ No newline at end of file +37430 \ No newline at end of file diff --git a/src/libraries/FeeLibrary.sol b/src/libraries/FeeLibrary.sol index c35a3282..f1503921 100644 --- a/src/libraries/FeeLibrary.sol +++ b/src/libraries/FeeLibrary.sol @@ -24,7 +24,7 @@ library FeeLibrary { } function isStaticFeeTooLarge(uint24 self, uint24 maxFee) internal pure returns (bool) { - return self & STATIC_FEE_MASK >= maxFee; + return self & STATIC_FEE_MASK > maxFee; } function getStaticFee(uint24 self) internal pure returns (uint24) { diff --git a/src/pool-bin/BinPoolManager.sol b/src/pool-bin/BinPoolManager.sol index 38c413d4..af1486c6 100644 --- a/src/pool-bin/BinPoolManager.sol +++ b/src/pool-bin/BinPoolManager.sol @@ -101,8 +101,8 @@ contract BinPoolManager is IBinPoolManager, Fees, Extsload { override poolManagerMatch(address(key.poolManager)) { - /// @dev Accept up to FeeLibrary.TEN_PERCENT_FEE for fee. Add +1 as isStaticFeeTooLarge function checks >= - if (key.fee.isStaticFeeTooLarge(FeeLibrary.TEN_PERCENT_FEE + 1)) revert FeeTooLarge(); + /// @dev Accept up to FeeLibrary.TEN_PERCENT_FEE for fee + if (key.fee.isStaticFeeTooLarge(FeeLibrary.TEN_PERCENT_FEE)) revert FeeTooLarge(); uint16 binStep = key.parameters.getBinStep(); if (binStep < MIN_BIN_STEP) revert BinStepTooSmall(); diff --git a/src/pool-cl/CLPoolManager.sol b/src/pool-cl/CLPoolManager.sol index 5b2324d3..daf47c8d 100644 --- a/src/pool-cl/CLPoolManager.sol +++ b/src/pool-cl/CLPoolManager.sol @@ -326,7 +326,7 @@ contract CLPoolManager is ICLPoolManager, Fees, Extsload { function _fetchDynamicSwapFee(PoolKey memory key) internal view returns (uint24 dynamicSwapFee) { dynamicSwapFee = ICLDynamicFeeManager(address(key.hooks)).getFee(msg.sender, key); - if (dynamicSwapFee >= FeeLibrary.ONE_HUNDRED_PERCENT_FEE) revert FeeTooLarge(); + if (dynamicSwapFee > FeeLibrary.ONE_HUNDRED_PERCENT_FEE) revert FeeTooLarge(); } function _checkPoolInitialized(PoolId id) internal view { diff --git a/test/libraries/FeeLibrary.sol b/test/libraries/FeeLibrary.sol index d8c44a9c..27dd7601 100644 --- a/test/libraries/FeeLibrary.sol +++ b/test/libraries/FeeLibrary.sol @@ -38,6 +38,6 @@ contract FeeLibraryTest is Test { } function testFuzzIsStaicFeeTooLarge(uint24 self, uint24 maxFee) public { - assertEq(FeeLibrary.getStaticFee(self) >= maxFee, FeeLibrary.isStaticFeeTooLarge(self, maxFee)); + assertEq(FeeLibrary.getStaticFee(self) > maxFee, FeeLibrary.isStaticFeeTooLarge(self, maxFee)); } } diff --git a/test/pool-cl/CLPoolManager.t.sol b/test/pool-cl/CLPoolManager.t.sol index 73be8265..e3995e6c 100644 --- a/test/pool-cl/CLPoolManager.t.sol +++ b/test/pool-cl/CLPoolManager.t.sol @@ -153,14 +153,14 @@ contract CLPoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot { poolManager.initialize(key, TickMath.MIN_SQRT_RATIO, new bytes(0)); } - // 1000000 i.e. 100% overflow + // 1000000 i.e. 100% + 1 overflow { PoolKey memory key = PoolKey({ currency0: Currency.wrap(makeAddr("token0")), currency1: Currency.wrap(makeAddr("token1")), hooks: IHooks(address(0)), poolManager: poolManager, - fee: uint24(1000000), + fee: uint24(1000001), parameters: bytes32(uint256(0xa0000)) }); @@ -2339,7 +2339,7 @@ contract CLPoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot { parameters: bytes32(uint256(10) << 16) }); - clFeeManagerHook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE); + clFeeManagerHook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1); vm.expectRevert(IFees.FeeTooLarge.selector); poolManager.updateDynamicSwapFee(key); diff --git a/test/pool-cl/libraries/CLPoolSwapFee.t.sol b/test/pool-cl/libraries/CLPoolSwapFee.t.sol index d70cc875..3859fcaf 100644 --- a/test/pool-cl/libraries/CLPoolSwapFee.t.sol +++ b/test/pool-cl/libraries/CLPoolSwapFee.t.sol @@ -79,14 +79,14 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { function testPoolInitializeFailsWithTooLargeFee() public { // cl pool swap fee is capped at 1_000_000 - hook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE); + hook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1); vm.expectRevert(IFees.FeeTooLarge.selector); poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); { vm.expectRevert(IFees.FeeTooLarge.selector); - staticFeeKey.fee = FeeLibrary.ONE_HUNDRED_PERCENT_FEE; + staticFeeKey.fee = FeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1; poolManager.initialize(staticFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); } } @@ -95,7 +95,7 @@ contract CLPoolSwapFeeTest is Deployers, TokenFixture, Test { hook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE / 2); poolManager.initialize(dynamicFeeKey, SQRT_RATIO_1_1, ZERO_BYTES); - hook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE); + hook.setFee(FeeLibrary.ONE_HUNDRED_PERCENT_FEE + 1); vm.expectRevert(IFees.FeeTooLarge.selector); poolManager.updateDynamicSwapFee(dynamicFeeKey); }