diff --git a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap index f155baf0..b268fe15 100644 --- a/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testInitializeSucceedsWithHook.snap @@ -1 +1 @@ -109043 \ No newline at end of file +108918 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap index e1c11457..e534d85b 100644 --- a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap @@ -1 +1 @@ -92267 \ No newline at end of file +90480 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap index 5bb924f2..0d077daa 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap @@ -1 +1 @@ -67459 \ No newline at end of file +65672 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap index c0858253..636780b6 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap @@ -1 +1 @@ -151014 \ No newline at end of file +149227 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap index f7e8f0d4..5d28fd52 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap @@ -1 +1 @@ -68638 \ No newline at end of file +66851 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap index ed1259c2..eaa9ffe1 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap @@ -1 +1 @@ -54221 \ No newline at end of file +52432 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap index dee5f7eb..31d8ed91 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap @@ -1 +1 @@ -970211 \ No newline at end of file +968422 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap index 87abc625..f96b7202 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap @@ -1 +1 @@ -121725 \ No newline at end of file +119936 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap index 1a6589a9..395c80bf 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap @@ -1 +1 @@ -339401 \ No newline at end of file +337612 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap index 0a9f433f..55b19f4d 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap @@ -1 +1 @@ -56462 \ No newline at end of file +54673 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap index fc933d28..1d00d427 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap @@ -1 +1 @@ -93238 \ No newline at end of file +91450 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap index 4f7345a4..32af14df 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap @@ -1 +1 @@ -95223 \ No newline at end of file +93435 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap index 8d4f2e00..58d51107 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap @@ -1 +1 @@ -74667 \ No newline at end of file +72879 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap index 839f2405..32feee08 100644 --- a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap @@ -1 +1 @@ -321109 \ No newline at end of file +319320 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Burn.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Burn.snap index 05fa1e86..768aed05 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Burn.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Burn.snap @@ -1 +1 @@ -41898 \ No newline at end of file +41503 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Donate.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Donate.snap index 6f7169e0..730820c6 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Donate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Donate.snap @@ -1 +1 @@ -19774 \ No newline at end of file +19379 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap index 68e93996..107c8224 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Initialize.snap @@ -1 +1 @@ -37243 \ No newline at end of file +37118 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Mint.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Mint.snap index dfa647e1..96a235a2 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Mint.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Mint.snap @@ -1 +1 @@ -39509 \ No newline at end of file +39114 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Swap.snap b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Swap.snap index afc7e3e9..22f01544 100644 --- a/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Swap.snap +++ b/.forge-snapshots/BinPoolManagerTest#testNoOpGas_Swap.snap @@ -1 +1 @@ -22897 \ No newline at end of file +22502 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap index 58094620..d16c4297 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap @@ -1 +1 @@ -350592 \ No newline at end of file +348803 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap index eaa8d203..1416f250 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap @@ -1 +1 @@ -61140 \ No newline at end of file +59351 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap index 0c339142..b3698c39 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap @@ -1 +1 @@ -243530 \ No newline at end of file +242396 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap b/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap index d791b879..e26f703b 100644 --- a/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap +++ b/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap @@ -1 +1 @@ -84302 \ No newline at end of file +82513 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap b/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap index 531c812a..07314794 100644 --- a/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap +++ b/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap @@ -1 +1 @@ -53609 \ No newline at end of file +52475 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap index c852e3e8..8812e0dc 100644 --- a/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#initializeWithoutHooks.snap @@ -1 +1 @@ -36544 \ No newline at end of file +36547 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap b/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap index b8dc4e62..144687f1 100644 --- a/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap @@ -1 +1 @@ -43462 \ No newline at end of file +42329 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap index 03c2391a..9133969d 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap @@ -1 +1 @@ -56609 \ No newline at end of file +54821 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap b/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap index 67181a11..107cd3d2 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap @@ -1 +1 @@ -104707 \ No newline at end of file +102919 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap b/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap index d28d3b1b..061bff6f 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap @@ -1 +1 @@ -25044433 \ No newline at end of file +25042645 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_simple.snap b/.forge-snapshots/CLPoolManagerTest#swap_simple.snap index 9cf1240d..b1fc476a 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_simple.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_simple.snap @@ -1 +1 @@ -36500 \ No newline at end of file +36021 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap index d71a9747..1f0b6296 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap @@ -1 +1 @@ -103205 \ No newline at end of file +101418 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap index 060443b8..7d787d98 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap @@ -1 +1 @@ -42150 \ No newline at end of file +41671 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap b/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap index 907cc5b2..2d8405df 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap @@ -1 +1 @@ -36503 \ No newline at end of file +36024 \ 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_Donate.snap b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Donate.snap index eda3bfd7..3370ca27 100644 --- a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Donate.snap +++ b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Donate.snap @@ -1 +1 @@ -19612 \ No newline at end of file +19217 \ 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 b6e10272..91c6b09a 100644 --- a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap +++ b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Initialize.snap @@ -1 +1 @@ -37494 \ No newline at end of file +37497 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_ModifyPosition.snap b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_ModifyPosition.snap index 9dbad8f8..57b636d7 100644 --- a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_ModifyPosition.snap +++ b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_ModifyPosition.snap @@ -1 +1 @@ -29755 \ No newline at end of file +29360 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap index de51cdc1..667ca99f 100644 --- a/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap +++ b/.forge-snapshots/CLPoolManagerTest#testNoOp_gas_Swap.snap @@ -1 +1 @@ -22061 \ No newline at end of file +21666 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#Vault.snap b/.forge-snapshots/VaultTest#Vault.snap index 6a3a44ed..85d18717 100644 --- a/.forge-snapshots/VaultTest#Vault.snap +++ b/.forge-snapshots/VaultTest#Vault.snap @@ -1 +1 @@ -7033 \ No newline at end of file +7180 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#lockSettledWhenAddLiquidity.snap b/.forge-snapshots/VaultTest#lockSettledWhenAddLiquidity.snap index cbf29f3c..830ad9f8 100644 --- a/.forge-snapshots/VaultTest#lockSettledWhenAddLiquidity.snap +++ b/.forge-snapshots/VaultTest#lockSettledWhenAddLiquidity.snap @@ -1 +1 @@ -122519 \ No newline at end of file +120730 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#lockSettledWhenFlashloan.snap b/.forge-snapshots/VaultTest#lockSettledWhenFlashloan.snap index 932d963e..02c149c9 100644 --- a/.forge-snapshots/VaultTest#lockSettledWhenFlashloan.snap +++ b/.forge-snapshots/VaultTest#lockSettledWhenFlashloan.snap @@ -1 +1 @@ -158811 \ No newline at end of file +156938 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#lockSettledWhenMultiHopSwap.snap b/.forge-snapshots/VaultTest#lockSettledWhenMultiHopSwap.snap index 37e2ed50..d816d6d9 100644 --- a/.forge-snapshots/VaultTest#lockSettledWhenMultiHopSwap.snap +++ b/.forge-snapshots/VaultTest#lockSettledWhenMultiHopSwap.snap @@ -1 +1 @@ -46974 \ No newline at end of file +45186 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#lockSettledWhenSwap.snap b/.forge-snapshots/VaultTest#lockSettledWhenSwap.snap index e6f87cf8..0a374883 100644 --- a/.forge-snapshots/VaultTest#lockSettledWhenSwap.snap +++ b/.forge-snapshots/VaultTest#lockSettledWhenSwap.snap @@ -1 +1 @@ -46973 \ No newline at end of file +45185 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#testLock_NoOp.snap b/.forge-snapshots/VaultTest#testLock_NoOp.snap index 8f91eb99..da1349a0 100644 --- a/.forge-snapshots/VaultTest#testLock_NoOp.snap +++ b/.forge-snapshots/VaultTest#testLock_NoOp.snap @@ -1 +1 @@ -11627 \ No newline at end of file +11232 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithMint.snap b/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithMint.snap index 540ef842..7a0dcd43 100644 --- a/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithMint.snap +++ b/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithMint.snap @@ -1 +1 @@ -72506 \ No newline at end of file +71681 \ No newline at end of file diff --git a/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithoutMint.snap b/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithoutMint.snap index 6a51203d..fc54fab9 100644 --- a/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithoutMint.snap +++ b/.forge-snapshots/VaultTest#testSettleAndMintRefund_WithoutMint.snap @@ -1 +1 @@ -34113 \ No newline at end of file +33288 \ 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/libraries/SettlementGuard.sol b/src/libraries/SettlementGuard.sol index 4cefceaa..f9f0f9e3 100644 --- a/src/libraries/SettlementGuard.sol +++ b/src/libraries/SettlementGuard.sol @@ -10,9 +10,14 @@ import {IVault} from "../interfaces/IVault.sol"; /// - 1: uint256 unsettledDeltasCount /// - 2: mapping(address, mapping(Currency => int256)) currencyDelta library SettlementGuard { - uint256 constant LOCKER_SLOT = uint256(keccak256("SETTLEMENT_LOCKER")) - 1; - uint256 constant UNSETTLED_DELTAS_COUNT = uint256(keccak256("SETTLEMENT_UNSETTLEMENTD_DELTAS_COUNT")) - 1; - uint256 constant CURRENCY_DELTA = uint256(keccak256("SETTLEMENT_CURRENCY_DELTA")) - 1; + // uint256 constant LOCKER_SLOT = uint256(keccak256("SETTLEMENT_LOCKER")) - 1; + uint256 constant LOCKER_SLOT = 0xedda7c051899c54dd66eaf5e13c031326ab4729812a579bed198ab93fd313d70; + + // uint256 constant UNSETTLED_DELTAS_COUNT = uint256(keccak256("SETTLEMENT_UNSETTLEMENTD_DELTAS_COUNT")) - 1; + uint256 constant UNSETTLED_DELTAS_COUNT = 0xa88ffc6a483ae852b901fb1c3a0df606e2e4461b493434e6643ebdc3ffabd151; + + // uint256 constant CURRENCY_DELTA = uint256(keccak256("SETTLEMENT_CURRENCY_DELTA")) - 1; + uint256 constant CURRENCY_DELTA = 0x6dc13502b9ba2a9e8e42c53a1856d632b29d5aab3bcb4a2476bfec06cbd9cf22; function setLocker(address newLocker) internal { address currentLocker = getLocker(); diff --git a/src/pool-bin/BinPoolManager.sol b/src/pool-bin/BinPoolManager.sol index 23b377d1..3bd91ccb 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 49fd0f60..7e831347 100644 --- a/src/pool-cl/CLPoolManager.sol +++ b/src/pool-cl/CLPoolManager.sol @@ -331,7 +331,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 f76f7284..5c283385 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)) }); @@ -300,7 +300,7 @@ contract CLPoolManagerTest is Test, Deployers, TokenFixture, GasSnapshot { key.hooks = IHooks(address(0)); key.poolManager = poolManager; - if (key.fee & FeeLibrary.STATIC_FEE_MASK >= FeeLibrary.ONE_HUNDRED_PERCENT_FEE) { + if (key.fee & FeeLibrary.STATIC_FEE_MASK > FeeLibrary.ONE_HUNDRED_PERCENT_FEE) { vm.expectRevert(abi.encodeWithSelector(IFees.FeeTooLarge.selector)); poolManager.initialize(key, sqrtPriceX96, ZERO_BYTES); } else if (key.parameters.getTickSpacing() > poolManager.MAX_TICK_SPACING()) { @@ -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); }