Skip to content

Commit

Permalink
s48: use directive with global
Browse files Browse the repository at this point in the history
  • Loading branch information
ChefMist committed Jan 26, 2025
1 parent 0ed117d commit 1eb930f
Show file tree
Hide file tree
Showing 36 changed files with 14 additions and 54 deletions.
2 changes: 2 additions & 0 deletions src/libraries/PathKey.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,8 @@ struct PathKey {
bytes32 parameters;
}

using PathKeyLibrary for PathKey global;

library PathKeyLibrary {
/// @notice Get the pool and swap direction for a given PathKey
/// @param params the given PathKey
Expand Down
4 changes: 2 additions & 2 deletions src/libraries/Planner.sol
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,10 @@ struct Plan {
bytes[] params;
}

using Planner for Plan global;

/// @notice Constructs a plan of actions to be executed on Pancakeswap v4.
library Planner {
using Planner for Plan;

function init() internal pure returns (Plan memory plan) {
return Plan({actions: bytes(""), params: new bytes[](0)});
}
Expand Down
1 change: 0 additions & 1 deletion src/pool-bin/BinMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {ReentrancyLock} from "../base/ReentrancyLock.sol";

contract BinMigrator is IBinMigrator, BaseMigrator, ReentrancyLock {
using SafeCast for uint256;
using Planner for Plan;

IBinPositionManager public immutable binPositionManager;

Expand Down
2 changes: 1 addition & 1 deletion src/pool-bin/BinPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ import {Currency, CurrencyLibrary} from "pancake-v4-core/src/types/Currency.sol"
import {IBinPoolManager} from "pancake-v4-core/src/pool-bin/interfaces/IBinPoolManager.sol";
import {BinPool} from "pancake-v4-core/src/pool-bin/libraries/BinPool.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";
import {LiquidityConfigurations} from "pancake-v4-core/src/pool-bin/libraries/math/LiquidityConfigurations.sol";
import {BinPoolParametersHelper} from "pancake-v4-core/src/pool-bin/libraries/BinPoolParametersHelper.sol";
import {PackedUint128Math} from "pancake-v4-core/src/pool-bin/libraries/math/PackedUint128Math.sol";
Expand Down
1 change: 0 additions & 1 deletion src/pool-bin/BinRouterBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {DeltaResolver} from "../base/DeltaResolver.sol";
import {ActionConstants} from "../libraries/ActionConstants.sol";

abstract contract BinRouterBase is IBinRouterBase, DeltaResolver {
using PathKeyLibrary for PathKey;
using SafeCastTemp for *;
using SafeCast for *;

Expand Down
4 changes: 1 addition & 3 deletions src/pool-bin/lens/BinQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import {BalanceDelta} from "pancake-v4-core/src/types/BalanceDelta.sol";
import {Currency} from "pancake-v4-core/src/types/Currency.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {SafeCast} from "pancake-v4-core/src/pool-bin/libraries/math/SafeCast.sol";
import {PoolId, PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";
import {IBinQuoter} from "../interfaces/IBinQuoter.sol";
import {PathKey, PathKeyLibrary} from "../../libraries/PathKey.sol";
import {BaseV4Quoter} from "../../base/BaseV4Quoter.sol";
Expand All @@ -18,8 +18,6 @@ import {QuoterRevert} from "../../libraries/QuoterRevert.sol";
contract BinQuoter is BaseV4Quoter, IBinQuoter {
using QuoterRevert for *;
using SafeCast for uint128;
using PathKeyLibrary for PathKey;
using PoolIdLibrary for PoolId;

IBinPoolManager public immutable poolManager;

Expand Down
2 changes: 0 additions & 2 deletions src/pool-cl/CLMigrator.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,6 @@ import {Plan, Planner} from "../libraries/Planner.sol";
import {ReentrancyLock} from "../base/ReentrancyLock.sol";

contract CLMigrator is ICLMigrator, BaseMigrator, ReentrancyLock {
using Planner for Plan;

ICLPositionManager public immutable clPositionManager;
ICLPoolManager public immutable clPoolManager;

Expand Down
1 change: 0 additions & 1 deletion src/pool-cl/CLRouterBase.sol
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ import {DeltaResolver} from "../base/DeltaResolver.sol";
import {ActionConstants} from "../libraries/ActionConstants.sol";

abstract contract CLRouterBase is ICLRouterBase, DeltaResolver {
using PathKeyLibrary for PathKey;
using SafeCastTemp for *;

ICLPoolManager public immutable clPoolManager;
Expand Down
4 changes: 1 addition & 3 deletions src/pool-cl/lens/CLQuoter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {TickMath} from "pancake-v4-core/src/pool-cl/libraries/TickMath.sol";
import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolManager.sol";
import {BalanceDelta} from "pancake-v4-core/src/types/BalanceDelta.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";
import {ICLQuoter} from "../interfaces/ICLQuoter.sol";
import {PoolTicksCounter} from "../libraries/PoolTicksCounter.sol";
import {PathKey, PathKeyLibrary} from "../../libraries/PathKey.sol";
Expand All @@ -16,8 +16,6 @@ import {Currency} from "pancake-v4-core/src/types/Currency.sol";

contract CLQuoter is ICLQuoter, BaseV4Quoter {
using QuoterRevert for *;
using PathKeyLibrary for PathKey;
using PoolIdLibrary for PoolId;

ICLPoolManager public immutable poolManager;

Expand Down
3 changes: 1 addition & 2 deletions src/pool-cl/lens/TickLens.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,15 +3,14 @@
pragma solidity 0.8.26;

import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolId, PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {PoolId} from "pancake-v4-core/src/types/PoolId.sol";
import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolManager.sol";
import {CLPoolParametersHelper} from "pancake-v4-core/src/pool-cl/libraries/CLPoolParametersHelper.sol";
import {Tick} from "pancake-v4-core/src/pool-cl/libraries/Tick.sol";
import {ITickLens} from "../interfaces/ITickLens.sol";

/// @title Tick Lens contract
contract TickLens is ITickLens {
using PoolIdLibrary for PoolId;
using CLPoolParametersHelper for bytes32;

ICLPoolManager public immutable poolManager;
Expand Down
1 change: 0 additions & 1 deletion src/pool-cl/libraries/PoolTicksCounter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@ pragma solidity ^0.8.24;
import {CLPoolParametersHelper} from "pancake-v4-core/src/pool-cl/libraries/CLPoolParametersHelper.sol";
import {ICLPoolManager} from "pancake-v4-core/src/pool-cl/interfaces/ICLPoolManager.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";

/// @title Pool Ticks Counter
/// @notice Functions for counting the number of initialized ticks between two ticks
Expand Down
2 changes: 0 additions & 2 deletions test/BaseActionsRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@ import {Test} from "forge-std/Test.sol";
import {IVault, Vault} from "pancake-v4-core/src/Vault.sol";

contract BaseActionsRouterTest is Test {
using Planner for Plan;

MockBaseActionsRouter router;

function setUp() public {
Expand Down
1 change: 0 additions & 1 deletion test/MixedQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,6 @@ contract MixedQuoterTest is
using SafeCast for *;
using CLPoolParametersHelper for bytes32;
using BinPoolParametersHelper for bytes32;
using Planner for Plan;

error ContractSizeTooLarge(uint256 diff);

Expand Down
1 change: 0 additions & 1 deletion test/pool-bin/BinPositionManager_Delta.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {BinPool} from "pancake-v4-core/src/pool-bin/libraries/BinPool.sol";

// test on the various way to perform delta resolver
contract BinPositionManager_DeltaTest is BinLiquidityHelper, TokenFixture, DeployPermit2 {
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using SafeCast for uint256;
using BinTokenLibrary for PoolId;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {IWETH9} from "../../src/interfaces/external/IWETH9.sol";
import {CustomRevert} from "pancake-v4-core/src/libraries/CustomRevert.sol";

contract BinPositionManager_ModifyLiquidityWithoutLockTest is BinLiquidityHelper, TokenFixture, DeployPermit2 {
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using SafeCast for uint256;
using BinTokenLibrary for PoolId;
Expand Down
1 change: 0 additions & 1 deletion test/pool-bin/BinPositionManager_ModifyLiquidites.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {BinPool} from "pancake-v4-core/src/pool-bin/libraries/BinPool.sol";
import {MockFOT} from "../mocks/MockFeeOnTransfer.sol";

contract BinPositionManager_ModifyLiquidityTest is BinLiquidityHelper, TokenFixture, DeployPermit2 {
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using SafeCast for uint256;
using BinTokenLibrary for PoolId;
Expand Down
1 change: 0 additions & 1 deletion test/pool-bin/BinPositionManager_MultiCall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,6 @@ contract BinPositionManager_MultiCallTest is
TokenFixture,
DeployPermit2
{
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using SafeCast for uint256;
using BinTokenLibrary for PoolId;
Expand Down
1 change: 0 additions & 1 deletion test/pool-bin/BinPositionManager_NativeToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,6 @@ import {BinPool} from "pancake-v4-core/src/pool-bin/libraries/BinPool.sol";

// test on the native token pair etc..
contract BinPositionManager_NativeTokenTest is BinLiquidityHelper, DeployPermit2 {
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using SafeCast for uint256;
using BinTokenLibrary for PoolId;
Expand Down
2 changes: 0 additions & 2 deletions test/pool-bin/BinQuoter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,9 +35,7 @@ import {IWETH9} from "../../src/interfaces/external/IWETH9.sol";

contract BinQuoterTest is Test, BinLiquidityHelper, DeployPermit2 {
using SafeCast for uint256;
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using Planner for Plan;

error ContractSizeTooLarge(uint256 diff);

Expand Down
4 changes: 1 addition & 3 deletions test/pool-bin/BinSwapRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -31,9 +31,7 @@ import {IWETH9} from "../../src/interfaces/external/IWETH9.sol";

contract BinSwapRouterTest is Test, BinLiquidityHelper, DeployPermit2 {
using SafeCast for uint256;
using Planner for Plan;
using BinPoolParametersHelper for bytes32;
using Planner for Plan;

bytes constant ZERO_BYTES = new bytes(0);
uint256 _deadline = block.timestamp + 1;
Expand Down Expand Up @@ -403,7 +401,7 @@ contract BinSwapRouterTest is Test, BinLiquidityHelper, DeployPermit2 {
data = plan.finalizeSwap(key.currency1, key.currency0, alice);
}
router.executeActions(data);
vm.snapshotGasLastCall("testExactOutputSingle_SwapForY");
vm.snapshotGasLastCall(gasSnapshotName);

// amountIn is 501504513540621866
if (swapForY) {
Expand Down
1 change: 0 additions & 1 deletion test/pool-bin/helper/BinLiquidityHelper.sol
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@ import {BinPositionManager} from "../../../src/pool-bin/BinPositionManager.sol";
import {Planner, Plan} from "../../../src/libraries/Planner.sol";

contract BinLiquidityHelper is Test {
using Planner for Plan;
using SafeCast for uint256;

/// @dev helper method to approve token0/token1 of poolKey to binPositionManager
Expand Down
2 changes: 0 additions & 2 deletions test/pool-cl/CLSwapRouter.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,6 @@ import {Actions} from "../../src/libraries/Actions.sol";
import {ActionConstants} from "../../src/libraries/ActionConstants.sol";

contract CLSwapRouterTest is TokenFixture, Test {
using Planner for Plan;

IVault public vault;
ICLPoolManager public poolManager;
CLPoolManagerRouter public positionManager;
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/TickLens.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ import {ITickLens} from "../../src/pool-cl/interfaces/ITickLens.sol";
import {TickLens} from "../../src/pool-cl/lens/TickLens.sol";

contract TickLensTest is TokenFixture, Test {
using Planner for Plan;
using PoolIdLibrary for PoolId;
using CLPoolParametersHelper for bytes32;

Expand Down
2 changes: 0 additions & 2 deletions test/pool-cl/libraries/PositionInfoLibrary.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -3,12 +3,10 @@ pragma solidity ^0.8.24;

import "forge-std/Test.sol";
import {PoolKey} from "pancake-v4-core/src/types/PoolKey.sol";
import {PoolIdLibrary} from "pancake-v4-core/src/types/PoolId.sol";
import {CLPositionInfo, CLPositionInfoLibrary, PoolId} from "../../../src/pool-cl/libraries/CLPositionInfoLibrary.sol";

contract PositionInfoLibraryTest is Test {
using CLPositionInfoLibrary for CLPositionInfo;
using PoolIdLibrary for PoolKey;

function setUp() public {}

Expand Down
2 changes: 1 addition & 1 deletion test/pool-cl/mocks/MockCLBadSubscribers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -87,7 +87,7 @@ contract MockCLRevertSubscriber is ICLSubscriber {
revert TestRevert("notifyUnsubscribe");
}

function notifyBurn(uint256, address, CLPositionInfo, uint256, BalanceDelta) external {
function notifyBurn(uint256, address, CLPositionInfo, uint256, BalanceDelta) external pure {
revert TestRevert("notifyBurn");
}

Expand Down
11 changes: 4 additions & 7 deletions test/pool-cl/mocks/MockCLSubscriber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -48,13 +48,10 @@ contract MockCLSubscriber is ICLSubscriber {
feesAccrued = _feesAccrued;
}

function notifyBurn(
uint256 tokenId,
address owner,
CLPositionInfo info,
uint256 _liquidity,
BalanceDelta _feesAccrued
) external onlyByPosm {
function notifyBurn(uint256, address, CLPositionInfo, uint256 _liquidity, BalanceDelta _feesAccrued)
external
onlyByPosm
{
liquidity = _liquidity;
feesAccrued = _feesAccrued;
notifyBurnCount++;
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/position-managers/CLPositionManager.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@ import {MockCLSubscriber} from "../mocks/MockCLSubscriber.sol";

contract CLPositionManagerGasTest is Test, PosmTestSetup {
using FixedPointMathLib for uint256;
using Planner for Plan;
using CLPoolParametersHelper for bytes32;

IVault vault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ import {ActionConstants} from "../../../src/libraries/ActionConstants.sol";

contract CLPositionManagerIncreaseLiquidityTest is Test, PosmTestSetup, Fuzzers {
using FixedPointMathLib for uint256;
using Planner for Plan;
using FeeMath for ICLPositionManager;

IVault vault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,6 @@ import {CLPoolParametersHelper} from "pancake-v4-core/src/pool-cl/libraries/CLPo
import {BipsLibrary} from "../../../src/libraries/BipsLibrary.sol";

contract CLPositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityFuzzers {
using Planner for Plan;
using CLPoolParametersHelper for bytes32;
using BipsLibrary for uint256;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ import {Permit2Forwarder} from "../../../src/base/Permit2Forwarder.sol";

contract CLPositionManagerMulticallTest is Test, Permit2SignatureHelpers, PosmTestSetup, LiquidityFuzzers {
using FixedPointMathLib for uint256;
using Planner for Plan;
using CLPoolParametersHelper for bytes32;

IVault vault;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import {MockCLReenterHook} from "../mocks/MockCLReenterHook.sol";
import {CustomRevert} from "pancake-v4-core/src/libraries/CustomRevert.sol";

contract CLPositionManagerNotifierTest is Test, PosmTestSetup {
using Planner for Plan;
using CLPositionInfoLibrary for CLPositionInfo;

IVault vault;
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/position-managers/CLPositionManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ import {CLPositionDescriptorOffChain} from "../../../src/pool-cl/CLPositionDescr

contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers {
using FixedPointMathLib for uint256;
using Planner for Plan;
using CLPoolParametersHelper for bytes32;

error ContractSizeTooLarge(uint256 diff);
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/position-managers/Execute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@ import {PosmTestSetup} from "../shared/PosmTestSetup.sol";

contract ExecuteTest is Test, PosmTestSetup, LiquidityFuzzers {
using FixedPointMathLib for uint256;
using Planner for Plan;

IVault vault;
ICLPoolManager manager;
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/position-managers/NativeToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,6 @@ import {LiquidityFuzzers} from "../shared/fuzz/LiquidityFuzzers.sol";

contract NativeTokenTest is Test, PosmTestSetup, LiquidityFuzzers {
using FixedPointMathLib for uint256;
using Planner for Plan;
using SafeCast for *;
using SafeCastTemp for *;

Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/shared/CLLiquidityOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,6 @@ import {HookSavesDelta} from "./HookSavesDelta.sol";
import {ICLPositionDescriptor} from "../../../src/pool-cl/interfaces/ICLPositionDescriptor.sol";

abstract contract CLLiquidityOperations is CommonBase {
using Planner for Plan;
using SafeCastTemp for uint256;

CLPositionManager lpm;
Expand Down
1 change: 0 additions & 1 deletion test/pool-cl/shared/fuzz/LiquidityFuzzers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ import {Actions} from "../../../../src/libraries/Actions.sol";
import {Planner, Plan} from "../../../../src/libraries/Planner.sol";

contract LiquidityFuzzers is Fuzzers {
using Planner for Plan;
using CLPoolParametersHelper for bytes32;

function addFuzzyLiquidity(
Expand Down

0 comments on commit 1eb930f

Please sign in to comment.