From c88b41090467dfec2bf73b06bb077ff021ae40c0 Mon Sep 17 00:00:00 2001 From: saucepoint <98790946+saucepoint@users.noreply.github.com> Date: Thu, 19 Dec 2024 10:33:24 -0500 Subject: [PATCH] Remove mandatory IR (#421) * feat: add scoping to _increaseFromDeltas * feat: assign params to memory in _burn * feat: dont compile posm with ir * chore: gas * feat: change optimizer runs to be below size limit * revert compilation changes * regenerate snapshots with existing compilation parameters * restore new line --------- Co-authored-by: Abdulla Al-Kamil --- src/PositionManager.sol | 40 ++++++++++++++++++++-------------------- 1 file changed, 20 insertions(+), 20 deletions(-) diff --git a/src/PositionManager.sol b/src/PositionManager.sol index be718d4d..291f86f2 100644 --- a/src/PositionManager.sol +++ b/src/PositionManager.sol @@ -309,16 +309,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) = @@ -423,16 +426,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); }