From b615117f0ad3d56cc412c36326faf99d3380fbc9 Mon Sep 17 00:00:00 2001 From: ChefMist <133624774+ChefMist@users.noreply.github.com> Date: Tue, 9 Apr 2024 22:35:24 +0800 Subject: [PATCH 1/2] test: fix too many input rejected for CLFees (#13) --- test/pool-cl/CLFees.t.sol | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/test/pool-cl/CLFees.t.sol b/test/pool-cl/CLFees.t.sol index c152b3e8..6e5ea75b 100644 --- a/test/pool-cl/CLFees.t.sol +++ b/test/pool-cl/CLFees.t.sol @@ -97,9 +97,10 @@ contract CLFeesTest is Test, Deployers, TokenFixture, GasSnapshot { } function testNoProtocolFee(uint16 protocolSwapFee) public { - vm.assume(protocolSwapFee < 2 ** 16); - vm.assume(protocolSwapFee >> 8 >= 4); - vm.assume(protocolSwapFee % 256 >= 4); + // Early return instead of vm.assume (too many input rejected) + if (protocolSwapFee >= 2 ** 16) return; + if (protocolSwapFee >> 8 < 4) return; + if (protocolSwapFee % 256 < 4) return; protocolFeeController.setSwapFeeForPool(key.toId(), protocolSwapFee); manager.setProtocolFeeController(IProtocolFeeController(protocolFeeController)); From b93ad15764597f4f2f5a8c5152edd19cb7fb136a Mon Sep 17 00:00:00 2001 From: chef-burger <137024020+chefburger@users.noreply.github.com> Date: Wed, 10 Apr 2024 21:18:21 +0800 Subject: [PATCH 2/2] optimization: getter method for easy access tick and bitmap (#16) --- .forge-snapshots/CLPoolManagerTest#setLmPool.snap | 2 +- .forge-snapshots/CLPoolManagerTest#setMasterChef.snap | 2 +- src/pool-cl/CLPoolManager.sol | 11 ++++++++++- 3 files changed, 12 insertions(+), 3 deletions(-) diff --git a/.forge-snapshots/CLPoolManagerTest#setLmPool.snap b/.forge-snapshots/CLPoolManagerTest#setLmPool.snap index 39deca12..a31e3566 100644 --- a/.forge-snapshots/CLPoolManagerTest#setLmPool.snap +++ b/.forge-snapshots/CLPoolManagerTest#setLmPool.snap @@ -1 +1 @@ -26272 \ No newline at end of file +26295 \ No newline at end of file diff --git a/.forge-snapshots/CLPoolManagerTest#setMasterChef.snap b/.forge-snapshots/CLPoolManagerTest#setMasterChef.snap index 48345f5c..19c0eed1 100644 --- a/.forge-snapshots/CLPoolManagerTest#setMasterChef.snap +++ b/.forge-snapshots/CLPoolManagerTest#setMasterChef.snap @@ -1 +1 @@ -30715 \ No newline at end of file +30760 \ No newline at end of file diff --git a/src/pool-cl/CLPoolManager.sol b/src/pool-cl/CLPoolManager.sol index 7e831347..f8ed16dd 100644 --- a/src/pool-cl/CLPoolManager.sol +++ b/src/pool-cl/CLPoolManager.sol @@ -2,6 +2,7 @@ // Copyright (C) 2024 PancakeSwap pragma solidity ^0.8.24; +import "./interfaces/ICLHooks.sol"; import {Fees} from "../Fees.sol"; import {ICLPoolManager} from "./interfaces/ICLPoolManager.sol"; import {IVault} from "../interfaces/IVault.sol"; @@ -10,9 +11,9 @@ import {CLPool} from "./libraries/CLPool.sol"; import {CLPosition} from "./libraries/CLPosition.sol"; import {PoolKey} from "../types/PoolKey.sol"; import {IPoolManager} from "../interfaces/IPoolManager.sol"; -import "./interfaces/ICLHooks.sol"; import {ICLDynamicFeeManager} from "./interfaces/ICLDynamicFeeManager.sol"; import {Hooks} from "../libraries/Hooks.sol"; +import {Tick} from "./libraries/Tick.sol"; import {CLPoolParametersHelper} from "./libraries/CLPoolParametersHelper.sol"; import {FeeLibrary} from "../libraries/FeeLibrary.sol"; import {PoolId, PoolIdLibrary} from "../types/PoolId.sol"; @@ -293,6 +294,14 @@ contract CLPoolManager is ICLPoolManager, Fees, Extsload { } } + function getPoolTickInfo(PoolId id, int24 tick) external view returns (Tick.Info memory) { + return pools[id].ticks[tick]; + } + + function getPoolBitmapInfo(PoolId id, int16 word) external view returns (uint256 tickBitmap) { + return pools[id].tickBitmap[word]; + } + /// @inheritdoc ICLPoolManager function setMasterChef(address _masterChef) external override onlyOwner { masterChef = _masterChef;