Skip to content

Commit

Permalink
Merge branch 'main' into refactor/swap-fee
Browse files Browse the repository at this point in the history
  • Loading branch information
chefburger committed Apr 12, 2024
2 parents 31eee89 + b93ad15 commit d3d3a5e
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 6 deletions.
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#setLmPool.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
26273
26296
2 changes: 1 addition & 1 deletion .forge-snapshots/CLPoolManagerTest#setMasterChef.snap
Original file line number Diff line number Diff line change
@@ -1 +1 @@
30715
30760
2 changes: 1 addition & 1 deletion src/libraries/SwapFeeLibrary.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ pragma solidity ^0.8.24;
/// @dev Library for parsing swap fee info from PoolKey.fee:
/// 24 bits (upper 4 bits are used to store flag, if swap fee is static, parse lower 20 bits to get swap fee)
/// 1. flag to indicate the activation of dynamic swap fee, otherwise static swap fee is used
/// - if dynamic swap fee is activated, then the swap fee is controlled by hook
/// - if dynamic swap fee is activated, then the swap fee can be updated by hook
/// - if dynamic swap fee is not activated, then the swap fee is controlled by PoolKey.fee itself
/// 2. protocol fee is controlled by protocolFeeController, not PoolKey.fee
/// - protocol fee is controlled by IProtocolFeeController(hook).protocolFeeForPool()
Expand Down
9 changes: 9 additions & 0 deletions src/pool-cl/CLPoolManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import {CLPosition} from "./libraries/CLPosition.sol";
import {PoolKey} from "../types/PoolKey.sol";
import {IPoolManager} from "../interfaces/IPoolManager.sol";
import {Hooks} from "../libraries/Hooks.sol";
import {Tick} from "./libraries/Tick.sol";
import {CLPoolParametersHelper} from "./libraries/CLPoolParametersHelper.sol";
import {SwapFeeLibrary} from "../libraries/SwapFeeLibrary.sol";
import {PoolId, PoolIdLibrary} from "../types/PoolId.sol";
Expand Down Expand Up @@ -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;
Expand Down
7 changes: 4 additions & 3 deletions test/pool-cl/CLFees.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down

0 comments on commit d3d3a5e

Please sign in to comment.