diff --git a/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap index 6d46032..b2f6f3f 100644 --- a/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testBurnSucceedsWithHook.snap @@ -1 +1 @@ -178372 \ No newline at end of file +178321 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap index 28df8f1..01d3222 100644 --- a/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testDonateSucceedsWithHook.snap @@ -1 +1 @@ -188524 \ No newline at end of file +188513 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap index c3e1401..70b3d99 100644 --- a/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testMintSucceedsWithHook.snap @@ -1 +1 @@ -311573 \ No newline at end of file +311511 \ No newline at end of file diff --git a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap index e22c8a1..9996cb1 100644 --- a/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap +++ b/.forge-snapshots/BinHookTest#testSwapSucceedsWithHook.snap @@ -1 +1 @@ -189823 \ No newline at end of file +189812 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerBytecodeSize.snap b/.forge-snapshots/BinPoolManagerBytecodeSize.snap index 1da5980..1eda836 100644 --- a/.forge-snapshots/BinPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/BinPoolManagerBytecodeSize.snap @@ -1 +1 @@ -24384 \ No newline at end of file +24232 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap index 1624e41..501c53a 100644 --- a/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testBurnNativeCurrency.snap @@ -1 +1 @@ -133886 \ No newline at end of file +133846 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap index 63bea96..ebe0530 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnHalfBin.snap @@ -1 +1 @@ -142697 \ No newline at end of file +142646 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap index bba3bc4..0fb650f 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnNineBins.snap @@ -1 +1 @@ -290044 \ No newline at end of file +289677 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap index 0c6fbad..886838c 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasBurnOneBin.snap @@ -1 +1 @@ -127060 \ No newline at end of file +127019 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap index 044b2d2..ba75e2e 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasDonate.snap @@ -1 +1 @@ -118796 \ No newline at end of file +118785 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap index fbf6a7d..a86f2d3 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-1.snap @@ -1 +1 @@ -970977 \ No newline at end of file +970507 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap index c7bbf2a..dfa4cc8 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintNneBins-2.snap @@ -1 +1 @@ -330288 \ No newline at end of file +329818 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap index 8b0b445..81d7c1a 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-1.snap @@ -1 +1 @@ -337889 \ No newline at end of file +337827 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap index 48a42a5..8dc4e1b 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasMintOneBin-2.snap @@ -1 +1 @@ -140439 \ No newline at end of file +140377 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap index 7eb3abb..aefc0d9 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapMultipleBins.snap @@ -1 +1 @@ -173347 \ No newline at end of file +173336 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap index a472b93..4cb4deb 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapOverBigBinIdGate.snap @@ -1 +1 @@ -179376 \ No newline at end of file +179365 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap index 0b2d936..8ba2bbc 100644 --- a/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap +++ b/.forge-snapshots/BinPoolManagerTest#testGasSwapSingleBin.snap @@ -1 +1 @@ -133378 \ No newline at end of file +133367 \ No newline at end of file diff --git a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap index ecb4fb8..686b16e 100644 --- a/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap +++ b/.forge-snapshots/BinPoolManagerTest#testMintNativeCurrency.snap @@ -1 +1 @@ -304846 \ No newline at end of file +304784 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerBytecodeSize.snap b/.forge-snapshots/CLPoolManagerBytecodeSize.snap index 4de01e1..c3463c2 100644 --- a/.forge-snapshots/CLPoolManagerBytecodeSize.snap +++ b/.forge-snapshots/CLPoolManagerBytecodeSize.snap @@ -1 +1 @@ -21307 \ No newline at end of file +21220 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap index 6a736d0..b1a6f81 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromEmpty.snap @@ -1 +1 @@ -347635 \ No newline at end of file +347599 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap index 543343d..e1f0931 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_fromNonEmpty.snap @@ -1 +1 @@ -163106 \ No newline at end of file +163070 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap index 61c56c8..f551f14 100644 --- a/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap +++ b/.forge-snapshots/CLPoolManagerTest#addLiquidity_nativeToken.snap @@ -1 +1 @@ -238392 \ No newline at end of file +238356 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap b/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap index 78742e7..c9edc38 100644 --- a/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap +++ b/.forge-snapshots/CLPoolManagerTest#donateBothTokens.snap @@ -1 +1 @@ -163361 \ No newline at end of file +163350 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap b/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap index 3839ece..d7be518 100644 --- a/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap +++ b/.forge-snapshots/CLPoolManagerTest#gasDonateOneToken.snap @@ -1 +1 @@ -108308 \ No newline at end of file +108297 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap b/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap index d70bde7..08abc4d 100644 --- a/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap +++ b/.forge-snapshots/CLPoolManagerTest#removeLiquidity_toNonEmpty.snap @@ -1 +1 @@ -114866 \ No newline at end of file +112713 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap index f1634b5..cd254b6 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_againstLiquidity.snap @@ -1 +1 @@ -131100 \ No newline at end of file +131089 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap b/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap index 873d723..5ea8431 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_leaveSurplusTokenInVault.snap @@ -1 +1 @@ -163678 \ No newline at end of file +163667 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap b/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap index c11a9d2..537566d 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_runOutOfLiquidity.snap @@ -1 +1 @@ -149117 \ No newline at end of file +149106 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_simple.snap b/.forge-snapshots/CLPoolManagerTest#swap_simple.snap index b86c6c7..7be1b20 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_simple.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_simple.snap @@ -1 +1 @@ -71712 \ No newline at end of file +71701 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap index 41c22a2..29f6232 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_useSurplusTokenAsInput.snap @@ -1 +1 @@ -143353 \ No newline at end of file +143342 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap index ceba966..2bb200d 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_withHooks.snap @@ -1 +1 @@ -87984 \ No newline at end of file +87973 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap b/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap index e690d87..644373c 100644 --- a/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap +++ b/.forge-snapshots/CLPoolManagerTest#swap_withNative.snap @@ -1 +1 @@ -71715 \ No newline at end of file +71704 \ No newline at end of file diff --git a/src/base/Pausable.sol b/src/base/Pausable.sol index d7ef56f..904cbf9 100644 --- a/src/base/Pausable.sol +++ b/src/base/Pausable.sol @@ -2,7 +2,7 @@ pragma solidity ^0.8.20; /** - * @dev Copy from openZeppelin contracts(v5.0.0) (utils/Pausable.sol), and remove unnecessary functions. + * @dev Referenced from openZeppelin contracts(v5.0.0) (utils/Pausable.sol), removed unnecessary functions and gas optimization. * Contract module which allows children to implement an emergency stop * mechanism that can be triggered by an authorized account. * @@ -12,7 +12,7 @@ pragma solidity ^0.8.20; * simply including this module, only once the modifiers are put in place. */ abstract contract Pausable { - bool private _paused; + uint256 private _paused; /** * @dev Emitted when the pause is triggered by `account`. @@ -29,13 +29,6 @@ abstract contract Pausable { */ error EnforcedPause(); - /** - * @dev Initializes the contract in unpaused state. - */ - constructor() { - _paused = false; - } - /** * @dev Modifier to make a function callable only when the contract is not paused. * @@ -51,8 +44,10 @@ abstract contract Pausable { /** * @dev Returns true if the contract is paused, and false otherwise. */ - function paused() public view virtual returns (bool) { - return _paused; + function paused() public view virtual returns (bool res) { + assembly ("memory-safe") { + res := sload(_paused.slot) + } } /** @@ -72,7 +67,7 @@ abstract contract Pausable { * - The contract must not be paused. */ function _pause() internal virtual whenNotPaused { - _paused = true; + _paused = 1; emit Paused(msg.sender); } @@ -80,7 +75,7 @@ abstract contract Pausable { * @dev Returns to normal state. */ function _unpause() internal virtual { - _paused = false; + _paused = 0; emit Unpaused(msg.sender); } } diff --git a/src/pool-bin/libraries/BinPosition.sol b/src/pool-bin/libraries/BinPosition.sol index 3001eb0..d331553 100644 --- a/src/pool-bin/libraries/BinPosition.sol +++ b/src/pool-bin/libraries/BinPosition.sol @@ -19,20 +19,12 @@ library BinPosition { /// @param binId The bin id where the position's liquidity is added /// @param salt A unique value to differentiate between multiple positions in the same binId, by the same owner. Passed in by the caller. function calculatePositionKey(address owner, uint24 binId, bytes32 salt) internal pure returns (bytes32 key) { - // dev same as `positionKey = keccak256(abi.encodePacked(owner, binId, salt))` + // dev same as `positionKey = keccak256(abi.encodePacked(binId, owner, salt))` // make salt, binId, owner to be tightly packed in memory - // mstore in reverse order make sure latter can make use of the empty space in the former assembly ("memory-safe") { - let fmp := mload(0x40) - mstore(add(fmp, 0x23), salt) // salt at [0x23, 0x43) - mstore(add(fmp, 0x03), binId) // binId at [0x20, 0x23) - mstore(fmp, owner) // owner at [0x0c, 0x20) - key := keccak256(add(fmp, 0x0c), 0x37) // len is 55 bytes - - // now clean the memory we used - mstore(add(fmp, 0x40), 0) // fmp+0x40 held salt - mstore(add(fmp, 0x20), 0) // fmp+0x20 held binId, salt - mstore(fmp, 0) // fmp held owner + mstore(0x0, or(shl(160, binId), and(owner, 0xffffffffffffffffffffffffffffffffffffffff))) // binId at [0x09,0x0c), owner at [0x0c, 0x20) + mstore(0x20, salt) // salt at [0x20, 0x40) + key := keccak256(0x09, 0x37) } } diff --git a/src/pool-cl/CLPoolManager.sol b/src/pool-cl/CLPoolManager.sol index 01f99cf..a1982c2 100644 --- a/src/pool-cl/CLPoolManager.sol +++ b/src/pool-cl/CLPoolManager.sol @@ -127,7 +127,7 @@ contract CLPoolManager is ICLPoolManager, ProtocolFees, Extsload { bytes calldata hookData ) external override returns (BalanceDelta delta, BalanceDelta feeDelta) { // Do not allow add liquidity when paused() - if (paused() && params.liquidityDelta > 0) revert PoolPaused(); + if (params.liquidityDelta > 0 && paused()) revert PoolPaused(); PoolId id = key.toId(); CLPool.State storage pool = pools[id]; diff --git a/src/pool-cl/libraries/CLPosition.sol b/src/pool-cl/libraries/CLPosition.sol index e37a025..198293d 100644 --- a/src/pool-cl/libraries/CLPosition.sol +++ b/src/pool-cl/libraries/CLPosition.sol @@ -32,21 +32,18 @@ library CLPosition { pure returns (bytes32 key) { - // same as `positionKey = keccak256(abi.encodePacked(owner, tickLower, tickUpper, salt))` + // same as `positionKey = keccak256(abi.encodePacked(tickLower, tickUpper, owner, salt))` // make salt, tickUpper, tickLower, owner to be tightly packed in memory - // mstore in reverse order make sure latter can make use of the empty space in the former assembly ("memory-safe") { - let fmp := mload(0x40) - mstore(add(fmp, 0x26), salt) // salt at [0x26, 0x46) - mstore(add(fmp, 0x06), tickUpper) // tickUpper at [0x23, 0x26) - mstore(add(fmp, 0x03), tickLower) // tickLower at [0x20, 0x23) - mstore(fmp, owner) // owner at [0x0c, 0x20) - key := keccak256(add(fmp, 0x0c), 0x3a) // len is 58 bytes - - // now clean the memory we used since we don't need it anymore - mstore(add(fmp, 0x40), 0) // fmp+0x40 held salt - mstore(add(fmp, 0x20), 0) // fmp+0x20 held tickLower, tickUpper, salt - mstore(fmp, 0) // fmp held owner + mstore( + 0x0, + or( + shl(160, and(0xFFFFFF, tickUpper)), + or(shl(184, tickLower), and(owner, 0xffffffffffffffffffffffffffffffffffffffff)) + ) + ) // tickLower at [0x06, 0x09), tickUpper at [0x09,0x0c), owner at [0x0c, 0x20) + mstore(0x20, salt) // salt at [0x20, 0x40) + key := keccak256(0x06, 0x3a) // len is 58 bytes } } diff --git a/test/Extsload.t.sol b/test/Extsload.t.sol index 5646561..e2f942e 100644 --- a/test/Extsload.t.sol +++ b/test/Extsload.t.sol @@ -17,11 +17,11 @@ contract ExtsloadTest is Test, GasSnapshot { // | Name | Type | Slot | Offset | Bytes | Contract | // |-----------------------|----------------------------------------|------|--------|-------|---------------------------------------------| // | _owner | address | 0 | 0 | 20 | src/pool-cl/CLPoolManager.sol:CLPoolManager | - // | _paused | bool | 0 | 20 | 1 | src/pool-cl/CLPoolManager.sol:CLPoolManager | - // | hasPausableRole | mapping(address => bool) | 1 | 0 | 32 | src/pool-cl/CLPoolManager.sol:CLPoolManager | + // | _paused | uint256 | 1 | 0 | 32 | src/pool-cl/CLPoolManager.sol:CLPoolManager | // | protocolFeesAccrued | mapping(Currency => uint256) | 2 | 0 | 32 | src/pool-cl/CLPoolManager.sol:CLPoolManager | // | protocolFeeController | contract IProtocolFeeController | 3 | 0 | 20 | src/pool-cl/CLPoolManager.sol:CLPoolManager | // | pools | mapping(PoolId => struct CLPool.State) | 4 | 0 | 32 | src/pool-cl/CLPoolManager.sol:CLPoolManager | + // | poolIdToPoolKey | mapping(PoolId => struct PoolKey) | 5 | 0 | 32 | src/pool-cl/CLPoolManager.sol:CLPoolManager | ICLPoolManager poolManager; Loadable loadable = new Loadable(); @@ -34,21 +34,19 @@ contract ExtsloadTest is Test, GasSnapshot { } function testExtsload() public { - // as contract is not paused, slot0 is 0x0...0_owner_address, - // if paused, slot0 is 0x0...1_owner_address snapStart("ExtsloadTest#extsload"); bytes32 slot0 = poolManager.extsload(0x00); snapEnd(); - assertEq(abi.encode(slot0), abi.encode(address(this))); + assertEq(abi.encode(slot0), abi.encode(address(this))); // owner - bytes32 slot2 = poolManager.extsload(bytes32(uint256(0x02))); - assertEq(abi.encode(slot2), abi.encode(address(0xabcd))); + bytes32 slot2 = poolManager.extsload(bytes32(uint256(0x03))); + assertEq(abi.encode(slot2), abi.encode(address(0xabcd))); // protocolFeeController } function testExtsloadInBatch() public { bytes32[] memory slots = new bytes32[](2); slots[0] = 0x00; - slots[1] = bytes32(uint256(0x02)); + slots[1] = bytes32(uint256(0x03)); snapStart("ExtsloadTest#extsloadInBatch"); slots = poolManager.extsload(slots); snapEnd(); diff --git a/test/pool-bin/BinPoolManager.t.sol b/test/pool-bin/BinPoolManager.t.sol index f78dcff..a817c3e 100644 --- a/test/pool-bin/BinPoolManager.t.sol +++ b/test/pool-bin/BinPoolManager.t.sol @@ -872,7 +872,7 @@ contract BinPoolManagerTest is Test, GasSnapshot, BinTestHelper { poolManager.initialize(key, activeId, new bytes(0)); // verify poolId. - uint256 POOL_SLOT = 4; + uint256 POOL_SLOT = 5; snapStart("BinPoolManagerTest#testExtLoadPoolActiveId"); bytes32 slot0Bytes = poolManager.extsload(keccak256(abi.encode(key.toId(), POOL_SLOT))); snapEnd(); diff --git a/test/pool-bin/libraries/BinPosition.t.sol b/test/pool-bin/libraries/BinPosition.t.sol index 198987d..5029cb5 100644 --- a/test/pool-bin/libraries/BinPosition.t.sol +++ b/test/pool-bin/libraries/BinPosition.t.sol @@ -49,12 +49,12 @@ contract BinPositionTest is Test { function testFuzz_CalculatePositionKey(address owner, uint24 binId, bytes32 salt) public pure { bytes32 positionKey = BinPosition.calculatePositionKey(owner, binId, salt); - assertEq(positionKey, keccak256(abi.encodePacked(owner, binId, salt))); + assertEq(positionKey, keccak256(abi.encodePacked(binId, owner, salt))); } function testFuzz_GetPosition(address owner, uint24 binId, bytes32 salt, uint256 share) public { // manual keccak and add share - bytes32 key = keccak256(abi.encodePacked(owner, binId, salt)); + bytes32 key = keccak256(abi.encodePacked(binId, owner, salt)); _self.positions[key].addShare(share); // verify assembly version of keccak retrival works diff --git a/test/pool-cl/libraries/CLPosition.t.sol b/test/pool-cl/libraries/CLPosition.t.sol index 6e1b6a7..e6eb326 100644 --- a/test/pool-cl/libraries/CLPosition.t.sol +++ b/test/pool-cl/libraries/CLPosition.t.sol @@ -96,7 +96,7 @@ contract CLPositionTest is Test, GasSnapshot { pure { bytes32 positionKey = CLPosition.calculatePositionKey(owner, tickLower, tickUpper, salt); - assertEq(positionKey, keccak256(abi.encodePacked(owner, tickLower, tickUpper, salt))); + assertEq(positionKey, keccak256(abi.encodePacked(tickLower, tickUpper, owner, salt))); } function test_MixFuzz(address owner, int24 tickLower, int24 tickUpper, bytes32 salt, int128 liquidityDelta) @@ -106,7 +106,7 @@ contract CLPositionTest is Test, GasSnapshot { CLPosition.Info storage info = pool.positions.get(owner, tickLower, tickUpper, salt); info.update(liquidityDelta, 0, 0); - bytes32 key = keccak256(abi.encodePacked(owner, tickLower, tickUpper, salt)); + bytes32 key = keccak256(abi.encodePacked(tickLower, tickUpper, owner, salt)); assertEq(pool.positions[key].liquidity, uint128(liquidityDelta)); } }