Skip to content

Commit 96b183b

Browse files
authored
Merge branch 'main' into get-rid-of-unecessary-using-directives-1
2 parents 4107786 + c88b410 commit 96b183b

File tree

7 files changed

+45
-21
lines changed

7 files changed

+45
-21
lines changed

snapshots/PosMGasTest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,5 +38,6 @@
3838
"PositionManager_permit_twice": "44975",
3939
"PositionManager_subscribe": "87968",
4040
"PositionManager_unsubscribe": "62697",
41+
"position manager initcode hash (without constructor params, as uint256)": "81827502601055975118808937107769364319765058198432540518516360048852193272922",
4142
"positionManager bytecode size": "23877"
4243
}

snapshots/PositionDescriptorTest.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
11
{
2+
"position descriptor initcode hash (without constructor params, as uint256)": "88482580191959945449130293370700011665153263709859488839371600440410373093991",
23
"positionDescriptor bytecode size": "24110"
34
}

snapshots/V4RouterTest.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,5 +22,6 @@
2222
"V4Router_ExactOut3Hops_nativeOut": "224943",
2323
"V4Router_ExactOutputSingle": "133337",
2424
"V4Router_ExactOutputSingle_nativeIn_sweepETH": "126419",
25-
"V4Router_ExactOutputSingle_nativeOut": "119821"
25+
"V4Router_ExactOutputSingle_nativeOut": "119821",
26+
"router initcode hash (without constructor params, as uint256)": "27545762869727400677117557485685740862616789454191614676777323590122002226479"
2627
}

src/PositionManager.sol

Lines changed: 20 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -306,16 +306,19 @@ contract PositionManager is
306306
{
307307
(PoolKey memory poolKey, PositionInfo info) = getPoolAndPositionInfo(tokenId);
308308

309-
(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());
310-
311-
// Use the credit on the pool manager as the amounts for the mint.
312-
uint256 liquidity = LiquidityAmounts.getLiquidityForAmounts(
313-
sqrtPriceX96,
314-
TickMath.getSqrtPriceAtTick(info.tickLower()),
315-
TickMath.getSqrtPriceAtTick(info.tickUpper()),
316-
_getFullCredit(poolKey.currency0),
317-
_getFullCredit(poolKey.currency1)
318-
);
309+
uint256 liquidity;
310+
{
311+
(uint160 sqrtPriceX96,,,) = poolManager.getSlot0(poolKey.toId());
312+
313+
// Use the credit on the pool manager as the amounts for the mint.
314+
liquidity = LiquidityAmounts.getLiquidityForAmounts(
315+
sqrtPriceX96,
316+
TickMath.getSqrtPriceAtTick(info.tickLower()),
317+
TickMath.getSqrtPriceAtTick(info.tickUpper()),
318+
_getFullCredit(poolKey.currency0),
319+
_getFullCredit(poolKey.currency1)
320+
);
321+
}
319322

320323
// Note: The tokenId is used as the salt for this position, so every minted position has unique storage in the pool manager.
321324
(BalanceDelta liquidityDelta, BalanceDelta feesAccrued) =
@@ -420,16 +423,13 @@ contract PositionManager is
420423
if (liquidity > 0) {
421424
BalanceDelta liquidityDelta;
422425
// do not use _modifyLiquidity as we do not need to notify on modification for burns.
423-
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(
424-
poolKey,
425-
IPoolManager.ModifyLiquidityParams({
426-
tickLower: info.tickLower(),
427-
tickUpper: info.tickUpper(),
428-
liquidityDelta: -(liquidity.toInt256()),
429-
salt: bytes32(tokenId)
430-
}),
431-
hookData
432-
);
426+
IPoolManager.ModifyLiquidityParams memory params = IPoolManager.ModifyLiquidityParams({
427+
tickLower: info.tickLower(),
428+
tickUpper: info.tickUpper(),
429+
liquidityDelta: -(liquidity.toInt256()),
430+
salt: bytes32(tokenId)
431+
});
432+
(liquidityDelta, feesAccrued) = poolManager.modifyLiquidity(poolKey, params, hookData);
433433
// Slippage checks should be done on the principal liquidityDelta which is the liquidityDelta - feesAccrued
434434
(liquidityDelta - feesAccrued).validateMinOut(amount0Min, amount1Min);
435435
}

test/PositionDescriptor.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,13 @@ contract PositionDescriptorTest is Test, PosmTestSetup {
4040
deployAndApprovePosm(manager);
4141
}
4242

43+
function test_position_descriptor_initcodeHash() public {
44+
vm.snapshotValue(
45+
"position descriptor initcode hash (without constructor params, as uint256)",
46+
uint256(keccak256(abi.encodePacked(vm.getCode("PositionDescriptor.sol:PositionDescriptor"))))
47+
);
48+
}
49+
4350
function test_bytecodeSize_positionDescriptor() public {
4451
vm.snapshotValue("positionDescriptor bytecode size", address(positionDescriptor).code.length);
4552
}

test/position-managers/PositionManager.gas.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,6 +70,13 @@ contract PosMGasTest is Test, PosmTestSetup {
7070
sub = new MockSubscriber(lpm);
7171
}
7272

73+
function test_posm_initcodeHash() public {
74+
vm.snapshotValue(
75+
"position manager initcode hash (without constructor params, as uint256)",
76+
uint256(keccak256(abi.encodePacked(vm.getCode("PositionManager.sol:PositionManager"))))
77+
);
78+
}
79+
7380
function test_bytecodeSize_positionManager() public {
7481
vm.snapshotValue("positionManager bytecode size", address(lpm).code.length);
7582
}

test/router/V4Router.gas.t.sol

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,13 @@ contract V4RouterTest is RoutingTestHelpers {
2020
vm.snapshotValue("V4Router_Bytecode", address(router).code.length);
2121
}
2222

23+
function test_router_initcodeHash() public {
24+
vm.snapshotValue(
25+
"router initcode hash (without constructor params, as uint256)",
26+
uint256(keccak256(abi.encodePacked(vm.getCode("MockV4Router.sol:MockV4Router"))))
27+
);
28+
}
29+
2330
/*//////////////////////////////////////////////////////////////
2431
ERC20 -> ERC20 EXACT INPUT
2532
//////////////////////////////////////////////////////////////*/

0 commit comments

Comments
 (0)