From 9a8d9277313fe4228ea3bc97b5d184962d97055c Mon Sep 17 00:00:00 2001 From: Emily Williams Date: Thu, 5 Dec 2024 14:00:11 -0500 Subject: [PATCH] delete shadow vars in TWAMM --- .../TWAMM executTWAMMOrders 1 interval.snap | 2 +- .../TWAMM executTWAMMOrders 2 intervals.snap | 2 +- .../TWAMM executTWAMMOrders 3 intervals.snap | 2 +- ...ecutTWAMMOrders singleSell 1 interval.snap | 2 +- ...cutTWAMMOrders singleSell 2 intervals.snap | 2 +- ...ders singleSell oneForZero 1 interval.snap | 2 +- ...ers singleSell oneForZero 2 intervals.snap | 2 +- contracts/hooks/examples/TWAMM.sol | 26 +++++-------------- .../implementation/TWAMMImplementation.sol | 2 +- 9 files changed, 15 insertions(+), 27 deletions(-) diff --git a/.forge-snapshots/TWAMM executTWAMMOrders 1 interval.snap b/.forge-snapshots/TWAMM executTWAMMOrders 1 interval.snap index 73d35f77..55797903 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders 1 interval.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders 1 interval.snap @@ -1 +1 @@ -489956 \ No newline at end of file +489927 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders 2 intervals.snap b/.forge-snapshots/TWAMM executTWAMMOrders 2 intervals.snap index 930472fb..f7be0309 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders 2 intervals.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders 2 intervals.snap @@ -1 +1 @@ -595446 \ No newline at end of file +595404 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders 3 intervals.snap b/.forge-snapshots/TWAMM executTWAMMOrders 3 intervals.snap index ed0bcaea..16c6a71c 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders 3 intervals.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders 3 intervals.snap @@ -1 +1 @@ -692908 \ No newline at end of file +692853 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders singleSell 1 interval.snap b/.forge-snapshots/TWAMM executTWAMMOrders singleSell 1 interval.snap index cd90b5ba..f9c0f73d 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders singleSell 1 interval.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders singleSell 1 interval.snap @@ -1 +1 @@ -262040 \ No newline at end of file +262033 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders singleSell 2 intervals.snap b/.forge-snapshots/TWAMM executTWAMMOrders singleSell 2 intervals.snap index 45e0da90..ef955f46 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders singleSell 2 intervals.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders singleSell 2 intervals.snap @@ -1 +1 @@ -294150 \ No newline at end of file +294134 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 1 interval.snap b/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 1 interval.snap index 6ad6b87e..35b5771d 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 1 interval.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 1 interval.snap @@ -1 +1 @@ -256437 \ No newline at end of file +256430 \ No newline at end of file diff --git a/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 2 intervals.snap b/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 2 intervals.snap index e74ab30b..f1fb08bb 100644 --- a/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 2 intervals.snap +++ b/.forge-snapshots/TWAMM executTWAMMOrders singleSell oneForZero 2 intervals.snap @@ -1 +1 @@ -290599 \ No newline at end of file +290583 \ No newline at end of file diff --git a/contracts/hooks/examples/TWAMM.sol b/contracts/hooks/examples/TWAMM.sol index 42c4444c..54d96ce5 100644 --- a/contracts/hooks/examples/TWAMM.sol +++ b/contracts/hooks/examples/TWAMM.sol @@ -376,7 +376,6 @@ contract TWAMM is BaseHook, ITWAMM { if (orderPool0For1.sellRateCurrent != 0 && orderPool1For0.sellRateCurrent != 0) { pool = _advanceToNewTimestamp( self, - manager, key, AdvanceParams( expirationInterval, @@ -388,7 +387,6 @@ contract TWAMM is BaseHook, ITWAMM { } else { pool = _advanceTimestampForSinglePoolSell( self, - manager, key, AdvanceSingleParams( expirationInterval, @@ -410,14 +408,12 @@ contract TWAMM is BaseHook, ITWAMM { if (orderPool0For1.sellRateCurrent != 0 && orderPool1For0.sellRateCurrent != 0) { pool = _advanceToNewTimestamp( self, - manager, key, AdvanceParams(expirationInterval, block.timestamp, block.timestamp - prevTimestamp, pool) ); } else { pool = _advanceTimestampForSinglePoolSell( self, - manager, key, AdvanceSingleParams( expirationInterval, @@ -443,12 +439,10 @@ contract TWAMM is BaseHook, ITWAMM { PoolParamsOnExecute pool; } - function _advanceToNewTimestamp( - State storage self, - IPoolManager manager, - PoolKey memory poolKey, - AdvanceParams memory params - ) private returns (PoolParamsOnExecute memory) { + function _advanceToNewTimestamp(State storage self, PoolKey memory poolKey, AdvanceParams memory params) + private + returns (PoolParamsOnExecute memory) + { uint160 finalSqrtPriceX96; uint256 secondsElapsedX96 = params.secondsElapsed * FixedPoint96.Q96; @@ -467,15 +461,12 @@ contract TWAMM is BaseHook, ITWAMM { finalSqrtPriceX96 = TwammMath.getNewSqrtPriceX96(executionParams); (bool crossingInitializedTick, int24 tick) = - _isCrossingInitializedTick(params.pool, manager, poolKey, finalSqrtPriceX96); + _isCrossingInitializedTick(params.pool, poolKey, finalSqrtPriceX96); unchecked { if (crossingInitializedTick) { uint256 secondsUntilCrossingX96; (params.pool, secondsUntilCrossingX96) = _advanceTimeThroughTickCrossing( - self, - manager, - poolKey, - TickCrossingParams(tick, params.nextTimestamp, secondsElapsedX96, params.pool) + self, poolKey, TickCrossingParams(tick, params.nextTimestamp, secondsElapsedX96, params.pool) ); secondsElapsedX96 = secondsElapsedX96 - secondsUntilCrossingX96; } else { @@ -508,7 +499,6 @@ contract TWAMM is BaseHook, ITWAMM { function _advanceTimestampForSinglePoolSell( State storage self, - IPoolManager manager, PoolKey memory poolKey, AdvanceSingleParams memory params ) private returns (PoolParamsOnExecute memory) { @@ -523,7 +513,7 @@ contract TWAMM is BaseHook, ITWAMM { ); (bool crossingInitializedTick, int24 tick) = - _isCrossingInitializedTick(params.pool, manager, poolKey, finalSqrtPriceX96); + _isCrossingInitializedTick(params.pool, poolKey, finalSqrtPriceX96); if (crossingInitializedTick) { (, int128 liquidityNetAtTick) = manager.getTickLiquidity(poolKey.toId(), tick); @@ -579,7 +569,6 @@ contract TWAMM is BaseHook, ITWAMM { function _advanceTimeThroughTickCrossing( State storage self, - IPoolManager manager, PoolKey memory poolKey, TickCrossingParams memory params ) private returns (PoolParamsOnExecute memory, uint256) { @@ -622,7 +611,6 @@ contract TWAMM is BaseHook, ITWAMM { function _isCrossingInitializedTick( PoolParamsOnExecute memory pool, - IPoolManager manager, PoolKey memory poolKey, uint160 nextSqrtPriceX96 ) internal view returns (bool crossingInitializedTick, int24 nextTickInit) { diff --git a/test/shared/implementation/TWAMMImplementation.sol b/test/shared/implementation/TWAMMImplementation.sol index 5d3034b2..26fef2cf 100644 --- a/test/shared/implementation/TWAMMImplementation.sol +++ b/test/shared/implementation/TWAMMImplementation.sol @@ -31,6 +31,6 @@ contract TWAMMImplementation is TWAMM { PoolKey memory poolKey, uint160 nextSqrtPriceX96 ) external view returns (bool crossingInitializedTick, int24 nextTickInit) { - return _isCrossingInitializedTick(pool, poolManager, poolKey, nextSqrtPriceX96); + return _isCrossingInitializedTick(pool, poolKey, nextSqrtPriceX96); } }