From d6b0bd059092b5492a52e2ecc472e349cfd9c7c0 Mon Sep 17 00:00:00 2001 From: diana Date: Mon, 2 Dec 2024 14:25:18 -0500 Subject: [PATCH 1/2] unnecessary line of code (#408) * unnecessary line of code * forge clean --- .forge-snapshots/positionDescriptor bytecode size.snap | 2 +- src/PositionDescriptor.sol | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.forge-snapshots/positionDescriptor bytecode size.snap b/.forge-snapshots/positionDescriptor bytecode size.snap index 616fe551..60d759c4 100644 --- a/.forge-snapshots/positionDescriptor bytecode size.snap +++ b/.forge-snapshots/positionDescriptor bytecode size.snap @@ -1 +1 @@ -24177 \ No newline at end of file +24110 \ No newline at end of file diff --git a/src/PositionDescriptor.sol b/src/PositionDescriptor.sol index 34910d53..021cbd5e 100644 --- a/src/PositionDescriptor.sol +++ b/src/PositionDescriptor.sol @@ -118,8 +118,6 @@ contract PositionDescriptor is IPositionDescriptor { return CurrencyRatioSortOrder.DENOMINATOR_MORE; } else if (currency == WBTC) { return CurrencyRatioSortOrder.DENOMINATOR_MOST; - } else { - return 0; } } return 0; From 05ede298e04a44a4dfa8beb04d4b3d121b127e68 Mon Sep 17 00:00:00 2001 From: Alice <34962750+hensha256@users.noreply.github.com> Date: Mon, 2 Dec 2024 19:54:42 +0000 Subject: [PATCH 2/2] remove unnecessary length check (#406) * remove unnecessary length check * comments for clarity --------- Co-authored-by: Sara Reynolds <30504811+snreynolds@users.noreply.github.com> --- .forge-snapshots/PositionManager_collect_native.snap | 2 +- .forge-snapshots/PositionManager_collect_sameRange.snap | 2 +- .forge-snapshots/PositionManager_collect_withClose.snap | 2 +- .../PositionManager_collect_withTakePair.snap | 2 +- .../PositionManager_decreaseLiquidity_native.snap | 2 +- .../PositionManager_decreaseLiquidity_withClose.snap | 2 +- .../PositionManager_decreaseLiquidity_withTakePair.snap | 2 +- .forge-snapshots/PositionManager_decrease_burnEmpty.snap | 2 +- .../PositionManager_decrease_burnEmpty_native.snap | 2 +- .../PositionManager_decrease_sameRange_allLiquidity.snap | 2 +- .forge-snapshots/PositionManager_decrease_take_take.snap | 2 +- ...ositionManager_increaseLiquidity_erc20_withClose.snap | 2 +- ...onManager_increaseLiquidity_erc20_withSettlePair.snap | 2 +- .../PositionManager_increaseLiquidity_native.snap | 2 +- ...nManager_increase_autocompoundExactUnclaimedFees.snap | 2 +- ...ionManager_increase_autocompoundExcessFeesCredit.snap | 2 +- ...ositionManager_increase_autocompound_clearExcess.snap | 2 +- .forge-snapshots/positionManager bytecode size.snap | 2 +- src/libraries/CalldataDecoder.sol | 9 +++++---- 19 files changed, 23 insertions(+), 22 deletions(-) diff --git a/.forge-snapshots/PositionManager_collect_native.snap b/.forge-snapshots/PositionManager_collect_native.snap index df2c6fcf..86f96529 100644 --- a/.forge-snapshots/PositionManager_collect_native.snap +++ b/.forge-snapshots/PositionManager_collect_native.snap @@ -1 +1 @@ -148593 \ No newline at end of file +148571 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_sameRange.snap b/.forge-snapshots/PositionManager_collect_sameRange.snap index d5f6bc6f..e2b8005b 100644 --- a/.forge-snapshots/PositionManager_collect_sameRange.snap +++ b/.forge-snapshots/PositionManager_collect_sameRange.snap @@ -1 +1 @@ -157242 \ No newline at end of file +157220 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_withClose.snap b/.forge-snapshots/PositionManager_collect_withClose.snap index d5f6bc6f..e2b8005b 100644 --- a/.forge-snapshots/PositionManager_collect_withClose.snap +++ b/.forge-snapshots/PositionManager_collect_withClose.snap @@ -1 +1 @@ -157242 \ No newline at end of file +157220 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_collect_withTakePair.snap b/.forge-snapshots/PositionManager_collect_withTakePair.snap index a7d8032c..ccb34392 100644 --- a/.forge-snapshots/PositionManager_collect_withTakePair.snap +++ b/.forge-snapshots/PositionManager_collect_withTakePair.snap @@ -1 +1 @@ -156478 \ No newline at end of file +156456 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap index 15e513a0..c2b5120a 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_native.snap @@ -1 +1 @@ -114183 \ No newline at end of file +114165 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap index b13b88cd..bdea68d3 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_withClose.snap @@ -1 +1 @@ -122577 \ No newline at end of file +122555 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap b/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap index 627de811..8c20e971 100644 --- a/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap +++ b/.forge-snapshots/PositionManager_decreaseLiquidity_withTakePair.snap @@ -1 +1 @@ -121813 \ No newline at end of file +121791 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap index 28983a33..dbd7a9ac 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty.snap @@ -1 +1 @@ -138195 \ No newline at end of file +138177 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap b/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap index 9f6d1c14..4622f7b4 100644 --- a/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap +++ b/.forge-snapshots/PositionManager_decrease_burnEmpty_native.snap @@ -1 +1 @@ -131276 \ No newline at end of file +131258 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap b/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap index 397b72af..105b3001 100644 --- a/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap +++ b/.forge-snapshots/PositionManager_decrease_sameRange_allLiquidity.snap @@ -1 +1 @@ -135240 \ No newline at end of file +135218 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_decrease_take_take.snap b/.forge-snapshots/PositionManager_decrease_take_take.snap index 25671ee7..a34b498c 100644 --- a/.forge-snapshots/PositionManager_decrease_take_take.snap +++ b/.forge-snapshots/PositionManager_decrease_take_take.snap @@ -1 +1 @@ -123191 \ No newline at end of file +123169 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap index e20cbceb..0c144b4d 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withClose.snap @@ -1 +1 @@ -162441 \ No newline at end of file +162419 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap index 957d69b9..5b88c621 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_erc20_withSettlePair.snap @@ -1 +1 @@ -161305 \ No newline at end of file +161283 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increaseLiquidity_native.snap b/.forge-snapshots/PositionManager_increaseLiquidity_native.snap index c00b6978..dd90e5a5 100644 --- a/.forge-snapshots/PositionManager_increaseLiquidity_native.snap +++ b/.forge-snapshots/PositionManager_increaseLiquidity_native.snap @@ -1 +1 @@ -145318 \ No newline at end of file +145296 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap b/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap index 6ed7545e..6312e8dd 100644 --- a/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap +++ b/.forge-snapshots/PositionManager_increase_autocompoundExactUnclaimedFees.snap @@ -1 +1 @@ -138032 \ No newline at end of file +138010 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap b/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap index e08e83c4..cf908d5c 100644 --- a/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap +++ b/.forge-snapshots/PositionManager_increase_autocompoundExcessFeesCredit.snap @@ -1 +1 @@ -180216 \ No newline at end of file +180194 \ No newline at end of file diff --git a/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap b/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap index 7d47367c..c9779d02 100644 --- a/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap +++ b/.forge-snapshots/PositionManager_increase_autocompound_clearExcess.snap @@ -1 +1 @@ -150804 \ No newline at end of file +150782 \ No newline at end of file diff --git a/.forge-snapshots/positionManager bytecode size.snap b/.forge-snapshots/positionManager bytecode size.snap index 6f29cf46..404029b9 100644 --- a/.forge-snapshots/positionManager bytecode size.snap +++ b/.forge-snapshots/positionManager bytecode size.snap @@ -1 +1 @@ -19068 \ No newline at end of file +19060 \ No newline at end of file diff --git a/src/libraries/CalldataDecoder.sol b/src/libraries/CalldataDecoder.sol index 3c7a800c..496852bd 100644 --- a/src/libraries/CalldataDecoder.sol +++ b/src/libraries/CalldataDecoder.sol @@ -76,11 +76,8 @@ library CalldataDecoder { pure returns (uint256 tokenId, uint256 liquidity, uint128 amount0, uint128 amount1, bytes calldata hookData) { + // no length check performed, as there is a length check in `toBytes` assembly ("memory-safe") { - if lt(params.length, 0x80) { - mstore(0, SLICE_ERROR_SELECTOR) - revert(0x1c, 4) - } tokenId := calldataload(params.offset) liquidity := calldataload(add(params.offset, 0x20)) amount0 := calldataload(add(params.offset, 0x40)) @@ -96,6 +93,7 @@ library CalldataDecoder { pure returns (uint256 tokenId, uint128 amount0Max, uint128 amount1Max, bytes calldata hookData) { + // no length check performed, as there is a length check in `toBytes` assembly ("memory-safe") { tokenId := calldataload(params.offset) amount0Max := calldataload(add(params.offset, 0x20)) @@ -120,6 +118,7 @@ library CalldataDecoder { bytes calldata hookData ) { + // no length check performed, as there is a length check in `toBytes` assembly ("memory-safe") { poolKey := params.offset tickLower := calldataload(add(params.offset, 0xa0)) @@ -146,6 +145,7 @@ library CalldataDecoder { bytes calldata hookData ) { + // no length check performed, as there is a length check in `toBytes` assembly ("memory-safe") { poolKey := params.offset tickLower := calldataload(add(params.offset, 0xa0)) @@ -164,6 +164,7 @@ library CalldataDecoder { pure returns (uint256 tokenId, uint128 amount0Min, uint128 amount1Min, bytes calldata hookData) { + // no length check performed, as there is a length check in `toBytes` assembly ("memory-safe") { tokenId := calldataload(params.offset) amount0Min := calldataload(add(params.offset, 0x20))