Skip to content

Commit

Permalink
Merge branch 'main' into get-rid-of-unecessary-using-directives-1
Browse files Browse the repository at this point in the history
  • Loading branch information
snreynolds authored Dec 19, 2024
2 parents 4107786 + c88b410 commit 96b183b
Show file tree
Hide file tree
Showing 7 changed files with 45 additions and 21 deletions.
1 change: 1 addition & 0 deletions snapshots/PosMGasTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -38,5 +38,6 @@
"PositionManager_permit_twice": "44975",
"PositionManager_subscribe": "87968",
"PositionManager_unsubscribe": "62697",
"position manager initcode hash (without constructor params, as uint256)": "81827502601055975118808937107769364319765058198432540518516360048852193272922",
"positionManager bytecode size": "23877"
}
1 change: 1 addition & 0 deletions snapshots/PositionDescriptorTest.json
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
{
"position descriptor initcode hash (without constructor params, as uint256)": "88482580191959945449130293370700011665153263709859488839371600440410373093991",
"positionDescriptor bytecode size": "24110"
}
3 changes: 2 additions & 1 deletion snapshots/V4RouterTest.json
Original file line number Diff line number Diff line change
Expand Up @@ -22,5 +22,6 @@
"V4Router_ExactOut3Hops_nativeOut": "224943",
"V4Router_ExactOutputSingle": "133337",
"V4Router_ExactOutputSingle_nativeIn_sweepETH": "126419",
"V4Router_ExactOutputSingle_nativeOut": "119821"
"V4Router_ExactOutputSingle_nativeOut": "119821",
"router initcode hash (without constructor params, as uint256)": "27545762869727400677117557485685740862616789454191614676777323590122002226479"
}
40 changes: 20 additions & 20 deletions src/PositionManager.sol
Original file line number Diff line number Diff line change
Expand Up @@ -306,16 +306,19 @@ contract PositionManager is
{
(PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId);

(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());

// Use the credit on the pool manager as the amounts for the mint.
uint256 liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
TickMath.getSqrtPriceAtTick(info.tickLower()),
TickMath.getSqrtPriceAtTick(info.tickUpper()),
_getFullCredit(poolKey.currency0),
_getFullCredit(poolKey.currency1)
);
uint256 liquidity;
{
(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());

// Use the credit on the pool manager as the amounts for the mint.
liquidity = LiquidityAmounts.getLiquidityForAmounts(
sqrtPriceX96,
TickMath.getSqrtPriceAtTick(info.tickLower()),
TickMath.getSqrtPriceAtTick(info.tickUpper()),
_getFullCredit(poolKey.currency0),
_getFullCredit(poolKey.currency1)
);
}

// Note: The tokenId is used as the salt for this position, so every minted position has unique storage in the pool manager.
(BalanceDelta liquidityDelta, BalanceDelta feesAccrued) =
Expand Down Expand Up @@ -420,16 +423,13 @@ contract PositionManager is
if (liquidity > 0) {
BalanceDelta liquidityDelta;
// do not use _modifyLiquidity as we do not need to notify on modification for burns.
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(
poolKey,
IPoolManager.ModifyLiquidityParams({
tickLower: info.tickLower(),
tickUpper: info.tickUpper(),
liquidityDelta: -(liquidity.toInt256()),
salt: bytes32(tokenId)
}),
hookData
);
IPoolManager.ModifyLiquidityParams memory params = IPoolManager.ModifyLiquidityParams({
tickLower: info.tickLower(),
tickUpper: info.tickUpper(),
liquidityDelta: -(liquidity.toInt256()),
salt: bytes32(tokenId)
});
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(poolKey, params, hookData);
// Slippage checks should be done on the principal liquidityDelta which is the liquidityDelta - feesAccrued
(liquidityDelta - feesAccrued).validateMinOut(amount0Min, amount1Min);
}
Expand Down
7 changes: 7 additions & 0 deletions test/PositionDescriptor.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,13 @@ contract PositionDescriptorTest is Test, PosmTestSetup {
deployAndApprovePosm(manager);
}

function test_position_descriptor_initcodeHash() public {
vm.snapshotValue(
"position descriptor initcode hash (without constructor params, as uint256)",
uint256(keccak256(abi.encodePacked(vm.getCode("PositionDescriptor.sol:PositionDescriptor"))))
);
}

function test_bytecodeSize_positionDescriptor() public {
vm.snapshotValue("positionDescriptor bytecode size", address(positionDescriptor).code.length);
}
Expand Down
7 changes: 7 additions & 0 deletions test/position-managers/PositionManager.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,13 @@ contract PosMGasTest is Test, PosmTestSetup {
sub = new MockSubscriber(lpm);
}

function test_posm_initcodeHash() public {
vm.snapshotValue(
"position manager initcode hash (without constructor params, as uint256)",
uint256(keccak256(abi.encodePacked(vm.getCode("PositionManager.sol:PositionManager"))))
);
}

function test_bytecodeSize_positionManager() public {
vm.snapshotValue("positionManager bytecode size", address(lpm).code.length);
}
Expand Down
7 changes: 7 additions & 0 deletions test/router/V4Router.gas.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,13 @@ contract V4RouterTest is RoutingTestHelpers {
vm.snapshotValue("V4Router_Bytecode", address(router).code.length);
}

function test_router_initcodeHash() public {
vm.snapshotValue(
"router initcode hash (without constructor params, as uint256)",
uint256(keccak256(abi.encodePacked(vm.getCode("MockV4Router.sol:MockV4Router"))))
);
}

/*//////////////////////////////////////////////////////////////
ERC20 -> ERC20 EXACT INPUT
//////////////////////////////////////////////////////////////*/
Expand Down

0 comments on commit 96b183b

Please sign in to comment.