Skip to content

Commit

Permalink
rename
Browse files Browse the repository at this point in the history
  • Loading branch information
hensha256 committed Aug 4, 2024
1 parent 1ab5e6c commit 16d52f9
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 12 deletions.
6 changes: 5 additions & 1 deletion src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,11 @@ contract PositionManager is
}

/// @inheritdoc IPositionManager
function modifyLiquiditiesDirect(bytes calldata actions, bytes[] calldata params) external payable isNotLocked {
function modifyLiquiditiesWithoutUnlock(bytes calldata actions, bytes[] calldata params)
external
payable
isNotLocked
{
_executeActions(actions, params);
}

Expand Down
2 changes: 1 addition & 1 deletion src/interfaces/IPositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ interface IPositionManager is INotifier {
/// @dev This must be called by a contract that has already unlocked the v4 PoolManager
/// @param actions the actions to perform
/// @param params the parameters to provide for the actions
function modifyLiquiditiesDirect(bytes calldata actions, bytes[] calldata params) external payable;
function modifyLiquiditiesWithoutUnlock(bytes calldata actions, bytes[] calldata params) external payable;

/// Returns the ID that will be used for the next minted liquidity position
/// @return uint256 The next token ID
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 @@ -87,7 +87,7 @@ contract PositionManagerTest is Test, PosmTestSetup, LiquidityFuzzers {
TickMath.getSqrtPriceAtTick(params.tickUpper),
liquidityToAdd.toUint128()
);
// add extra wei because modifyLiquiditiesDirect may be rounding up, LiquidityAmounts is imprecise?
// add extra wei because modifyLiquidities may be rounding up, LiquidityAmounts is imprecise?
lpm.modifyLiquidities{value: amount0 + 1}(calls, _deadline);
BalanceDelta delta = getLastDelta();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF
approvePosmFor(alice);

// must deploy after posm
// Deploys a hook which can accesses IPositionManager.modifyLiquiditiesDirect
// Deploys a hook which can accesses IPositionManager.modifyLiquiditiesWithoutUnlock
deployPosmHookModifyLiquidities();
seedBalance(address(hookModifyLiquidities));

Expand Down Expand Up @@ -259,7 +259,7 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF
swap(key, true, -1e18, calls);
}

/// @dev hook cannot re-enter modifyLiquiditiesDirect in beforeRemoveLiquidity
/// @dev hook cannot re-enter modifyLiquiditiesWithoutUnlock in beforeRemoveLiquidity
function test_hook_increaseLiquidity_reenter_revert() public {
uint256 initialLiquidity = 100e18;
uint256 tokenId = lpm.nextTokenId();
Expand All @@ -271,7 +271,7 @@ contract PositionManagerModifyLiquiditiesTest is Test, PosmTestSetup, LiquidityF
bytes memory hookCall = getIncreaseEncoded(tokenId, config, newLiquidity, ZERO_BYTES);
bytes memory calls = getIncreaseEncoded(tokenId, config, newLiquidity, hookCall);

// should revert because hook is re-entering modifyLiquiditiesDirect
// should revert because hook is re-entering modifyLiquiditiesWithoutUnlock
vm.expectRevert(
abi.encodeWithSelector(
Hooks.FailedHookCall.selector, abi.encodeWithSelector(ReentrancyLock.ContractLocked.selector)
Expand Down
8 changes: 4 additions & 4 deletions test/shared/HookModifyLiquidities.sol
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ import {IERC20} from "forge-std/interfaces/IERC20.sol";

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

/// @notice This contract is NOT a production use contract. It is meant to be used in testing to verify that external contracts can modify liquidity without a lock (IPositionManager.modifyLiquiditiesDirect)
/// @notice This contract is NOT a production use contract. It is meant to be used in testing to verify that external contracts can modify liquidity without a lock (IPositionManager.modifyLiquiditiesWithoutUnlock)
/// @dev a hook that can modify liquidity in beforeSwap
contract HookModifyLiquidities is HookSavesDelta {
IPositionManager posm;
Expand All @@ -35,7 +35,7 @@ contract HookModifyLiquidities is HookSavesDelta {
approvePosmCurrency(key.currency1);

(bytes memory actions, bytes[] memory params) = abi.decode(hookData, (bytes, bytes[]));
posm.modifyLiquiditiesDirect(actions, params);
posm.modifyLiquiditiesWithoutUnlock(actions, params);
return (this.beforeSwap.selector, BeforeSwapDeltaLibrary.ZERO_DELTA, 0);
}

Expand All @@ -47,7 +47,7 @@ contract HookModifyLiquidities is HookSavesDelta {
) external override returns (bytes4) {
if (hookData.length > 0) {
(bytes memory actions, bytes[] memory params) = abi.decode(hookData, (bytes, bytes[]));
posm.modifyLiquiditiesDirect(actions, params);
posm.modifyLiquiditiesWithoutUnlock(actions, params);
}
return this.beforeAddLiquidity.selector;
}
Expand All @@ -60,7 +60,7 @@ contract HookModifyLiquidities is HookSavesDelta {
) external override returns (bytes4) {
if (hookData.length > 0) {
(bytes memory actions, bytes[] memory params) = abi.decode(hookData, (bytes, bytes[]));
posm.modifyLiquiditiesDirect(actions, params);
posm.modifyLiquiditiesWithoutUnlock(actions, params);
}
return this.beforeRemoveLiquidity.selector;
}
Expand Down
4 changes: 2 additions & 2 deletions test/shared/LiquidityOperations.sol
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ abstract contract LiquidityOperations is CommonBase {
liquidity.toUint128()
);
bytes memory calls = getMintEncoded(config, liquidity, recipient, hookData);
// add extra wei because modifyLiquiditiesDirect may be rounding up, LiquidityAmounts is imprecise?
// add extra wei because modifyLiquiditiesWithoutUnlock may be rounding up, LiquidityAmounts is imprecise?
lpm.modifyLiquidities{value: amount0 + 1}(calls, _deadline);
}

Expand Down Expand Up @@ -81,7 +81,7 @@ abstract contract LiquidityOperations is CommonBase {
lpm.modifyLiquidities(calls, _deadline);
}

// Helper functions for getting encoded calldata for .modifyLiquiditiesDirect
// Helper functions for getting encoded calldata for .modifyLiquiditiesWithoutUnlock
function getMintEncoded(PositionConfig memory config, uint256 liquidity, address recipient, bytes memory hookData)
internal
pure
Expand Down

0 comments on commit 16d52f9

Please sign in to comment.