From 8c28b05312f3d806cba57ebe73a179b17dbfa653 Mon Sep 17 00:00:00 2001 From: roleengineer Date: Sat, 17 Aug 2024 10:54:43 +0300 Subject: [PATCH] exact repeat of initial pulledHarb storage var. --- onchain/src/LiquidityManager.sol | 24 ++---------------------- 1 file changed, 2 insertions(+), 22 deletions(-) diff --git a/onchain/src/LiquidityManager.sol b/onchain/src/LiquidityManager.sol index 4d78c11..89b9de8 100644 --- a/onchain/src/LiquidityManager.sol +++ b/onchain/src/LiquidityManager.sol @@ -221,27 +221,6 @@ contract LiquidityManager { }); } - /// @notice calculates token0/token1 amount based on range and liquidity - /// @dev Use TOKEN_ZERO as tokenZero value, when need to calculate TOKEN amount - /// Use !TOKEN_ZERO as tokenZero value, when need to calculate WETH amount - function getAmountForLiquidity( - int24 tickLower, - int24 tickUpper, - uint128 liquidity, - bool tokenZero - ) - internal - pure - returns (uint256 amount) - { - uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower); - uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper); - - amount = tokenZero - ? LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity) - : LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioBX96, liquidity); - } - /// @notice Internal function to set or adjust the floor, anchor, and discovery positions based on current market conditions and the manager's strategy. /// @param currentTick The current market tick. /// @dev Recalculates and realigns all liquidity positions according to the latest market data and strategic requirements. @@ -283,12 +262,13 @@ contract LiquidityManager { anchorLiquidity = LiquidityAmounts.getLiquidityForAmount0( sqrtRatioX96, sqrtRatioBX96, anchorEthBalance ); + pulledHarb = LiquidityAmounts.getAmount1ForLiquidity(sqrtRatioAX96, sqrtRatioX96, anchorLiquidity); } else { anchorLiquidity = LiquidityAmounts.getLiquidityForAmount1( sqrtRatioAX96, sqrtRatioX96, anchorEthBalance ); + pulledHarb = LiquidityAmounts.getAmount0ForLiquidity(sqrtRatioX96, sqrtRatioBX96, anchorLiquidity); } - pulledHarb = getAmountForLiquidity(tickLower, tickUpper, anchorLiquidity, !token0isWeth); _mint(Stage.ANCHOR, tickLower, tickUpper, anchorLiquidity); } currentTick = currentTick / TICK_SPACING * TICK_SPACING;