Skip to content

Commit

Permalink
move PositionConfig to shared testing infra
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds committed Aug 29, 2024
1 parent 31a22de commit ca37b8c
Show file tree
Hide file tree
Showing 21 changed files with 15 additions and 38 deletions.
1 change: 0 additions & 1 deletion src/interfaces/INotifier.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import {PositionConfig} from "../libraries/PositionConfig.sol";
import {ISubscriber} from "./ISubscriber.sol";

/// @notice This interface is used to opt in to sending updates to external contracts about position modifications or transfers
Expand Down
1 change: 0 additions & 1 deletion src/interfaces/ISubscriber.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: UNLICENSED
pragma solidity ^0.8.24;

import {PositionConfig} from "../libraries/PositionConfig.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";

/// @notice Interface that a Subscriber contract should implement to receive updates from the v4 position manager
Expand Down
3 changes: 1 addition & 2 deletions src/libraries/CalldataDecoder.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: GPL-3.0-or-later
pragma solidity ^0.8.0;

import {PositionConfig} from "./PositionConfig.sol";
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
import {IV4Router} from "../interfaces/IV4Router.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";
Expand Down Expand Up @@ -45,7 +44,7 @@ library CalldataDecoder {
}
}

/// @dev equivalent to: abi.decode(params, (uint256, PositionConfig, uint256, uint128, uint128, bytes)) in calldata
/// @dev equivalent to: abi.decode(params, (uint256, uint256, uint128, uint128, bytes)) in calldata
function decodeModifyLiquidityParams(bytes calldata params)
internal
pure
Expand Down
18 changes: 1 addition & 17 deletions test/libraries/CalldataDecoder.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

import {MockCalldataDecoder} from "../mocks/MockCalldataDecoder.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {IV4Router} from "../../src/interfaces/IV4Router.sol";
import {PathKey} from "../../src/libraries/PathKey.sol";

Expand Down Expand Up @@ -51,7 +51,6 @@ contract CalldataDecoderTest is Test {
assertEq(amount1Min, _amount1Min);
}

// TODO: fix stack too deep here
function test_fuzz_decodeMintParams(
PositionConfig calldata _config,
uint256 _liquidity,
Expand Down Expand Up @@ -199,26 +198,11 @@ contract CalldataDecoderTest is Test {
}
}

function _assertEq(PositionConfig memory config1, PositionConfig memory config2) internal pure {
_assertEq(config1.poolKey, config2.poolKey);
assertEq(config1.tickLower, config2.tickLower);
assertEq(config1.tickUpper, config2.tickUpper);
}

function _assertEq(PoolKey memory key1, PoolKey memory key2) internal pure {
assertEq(Currency.unwrap(key1.currency0), Currency.unwrap(key2.currency0));
assertEq(Currency.unwrap(key1.currency1), Currency.unwrap(key2.currency1));
assertEq(key1.fee, key2.fee);
assertEq(key1.tickSpacing, key2.tickSpacing);
assertEq(address(key1.hooks), address(key2.hooks));
}

function _assertEq(PositionConfig memory config, PoolKey memory poolKey, int24 tickLower, int24 tickUpper)
internal
pure
{
_assertEq(config.poolKey, poolKey);
assertEq(config.tickLower, tickLower);
assertEq(config.tickUpper, tickUpper);
}
}
1 change: 0 additions & 1 deletion test/mocks/MockBadSubscribers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.20;

import {ISubscriber} from "../../src/interfaces/ISubscriber.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";

Expand Down
1 change: 0 additions & 1 deletion test/mocks/MockCalldataDecoder.sol
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.24;

import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {CalldataDecoder} from "../../src/libraries/CalldataDecoder.sol";
import {IV4Router} from "../../src/interfaces/IV4Router.sol";
import {Currency} from "@uniswap/v4-core/src/types/Currency.sol";
Expand Down
1 change: 0 additions & 1 deletion test/mocks/MockSubscriber.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.20;

import {ISubscriber} from "../../src/interfaces/ISubscriber.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {BalanceDelta} from "@uniswap/v4-core/src/types/BalanceDelta.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/Execute.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {IERC20} from "forge-std/interfaces/IERC20.sol";

import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {ActionConstants} from "../../src/libraries/ActionConstants.sol";
import {Actions} from "../../src/libraries/Actions.sol";

Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/FeeCollection.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {FixedPointMathLib} from "solmate/src/utils/FixedPointMathLib.sol";
import {IERC20} from "forge-std/interfaces/IERC20.sol";

import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";

import {LiquidityFuzzers} from "../shared/fuzz/LiquidityFuzzers.sol";
import {PosmTestSetup} from "../shared/PosmTestSetup.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/IncreaseLiquidity.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {IERC20} from "forge-std/interfaces/IERC20.sol";

import {PositionManager} from "../../src/PositionManager.sol";
import {DeltaResolver} from "../../src/base/DeltaResolver.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {SlippageCheckLibrary} from "../../src/libraries/SlippageCheck.sol";
import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {Actions} from "../../src/libraries/Actions.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/NativeToken.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ import {MockSubscriber} from "../mocks/MockSubscriber.sol";
import {LiquidityFuzzers} from "../shared/fuzz/LiquidityFuzzers.sol";
import {PosmTestSetup} from "../shared/PosmTestSetup.sol";
import {Planner, Plan} from "../shared/Planner.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";

contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers {
using FixedPointMathLib for uint256;
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/Permit.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ import {IERC721Permit_v4} from "../../src/interfaces/IERC721Permit_v4.sol";
import {ERC721Permit_v4} from "../../src/base/ERC721Permit_v4.sol";
import {UnorderedNonce} from "../../src/base/UnorderedNonce.sol";

import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";

import {PosmTestSetup} from "../shared/PosmTestSetup.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ import {IERC20} from "forge-std/interfaces/IERC20.sol";
import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {Actions} from "../../src/libraries/Actions.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {IMulticall_v4} from "../../src/interfaces/IMulticall_v4.sol";
import {Planner, Plan} from "../shared/Planner.sol";
import {PosmTestSetup} from "../shared/PosmTestSetup.sol";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {ReentrancyLock} from "../../src/base/ReentrancyLock.sol";
import {Actions} from "../../src/libraries/Actions.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";

import {LiquidityFuzzers} from "../shared/fuzz/LiquidityFuzzers.sol";
import {Planner, Plan} from "../shared/Planner.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.multicall.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {PoolInitializer} from "../../src/base/PoolInitializer.sol";
import {Actions} from "../../src/libraries/Actions.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {IMulticall_v4} from "../../src/interfaces/IMulticall_v4.sol";
import {LiquidityFuzzers} from "../shared/fuzz/LiquidityFuzzers.sol";
import {Planner, Plan} from "../shared/Planner.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.notifier.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {GasSnapshot} from "forge-gas-snapshot/GasSnapshot.sol";
import {PosmTestSetup} from "../shared/PosmTestSetup.sol";
import {MockSubscriber} from "../mocks/MockSubscriber.sol";
import {ISubscriber} from "../../src/interfaces/ISubscriber.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {Plan, Planner} from "../shared/Planner.sol";
import {Actions} from "../../src/libraries/Actions.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/position-managers/PositionManager.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {Actions} from "../../src/libraries/Actions.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {DeltaResolver} from "../../src/base/DeltaResolver.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";
import {SlippageCheckLibrary} from "../../src/libraries/SlippageCheck.sol";
import {BaseActionsRouter} from "../../src/base/BaseActionsRouter.sol";
import {ActionConstants} from "../../src/libraries/ActionConstants.sol";
Expand Down
2 changes: 1 addition & 1 deletion test/shared/FeeMath.sol
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

import {IPositionManager} from "../../src/interfaces/IPositionManager.sol";
import {PositionManager} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "../shared/PositionConfig.sol";

library FeeMath {
using SafeCast for uint256;
Expand Down
2 changes: 1 addition & 1 deletion test/shared/LiquidityOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ import {LiquidityAmounts} from "@uniswap/v4-core/test/utils/LiquidityAmounts.sol
import {SafeCast} from "@uniswap/v4-core/src/libraries/SafeCast.sol";

import {PositionManager, Actions} from "../../src/PositionManager.sol";
import {PositionConfig} from "../../src/libraries/PositionConfig.sol";
import {PositionConfig} from "./PositionConfig.sol";
import {Planner, Plan} from "../shared/Planner.sol";
import {HookSavesDelta} from "./HookSavesDelta.sol";

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ pragma solidity ^0.8.24;

import {PoolKey} from "@uniswap/v4-core/src/types/PoolKey.sol";

// A PositionConfig is the input for creating and modifying a Position in core
// A helper struct used for tests
struct PositionConfig {
PoolKey poolKey;
int24 tickLower;
Expand Down
1 change: 0 additions & 1 deletion test/shared/fuzz/LiquidityFuzzers.sol
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import {Fuzzers} from "@uniswap/v4-core/src/test/Fuzzers.sol";

import {IPositionManager} from "../../../src/interfaces/IPositionManager.sol";
import {Actions} from "../../../src/libraries/Actions.sol";
import {PositionConfig} from "../../../src/libraries/PositionConfig.sol";
import {Planner, Plan} from "../../shared/Planner.sol";

contract LiquidityFuzzers is Fuzzers {
Expand Down

0 comments on commit ca37b8c

Please sign in to comment.