diff --git a/onchain/src/LiquidityManager.sol b/onchain/src/LiquidityManager.sol index 89b9de8..460e15e 100644 --- a/onchain/src/LiquidityManager.sol +++ b/onchain/src/LiquidityManager.sol @@ -274,13 +274,14 @@ contract LiquidityManager { currentTick = currentTick / TICK_SPACING * TICK_SPACING; // set Discovery position + uint256 discoveryAmount; { int24 tickLower = token0isWeth ? currentTick - DISCOVERY_SPACING - ANCHOR_SPACING : currentTick + ANCHOR_SPACING; int24 tickUpper = token0isWeth ? currentTick - ANCHOR_SPACING : currentTick + DISCOVERY_SPACING + ANCHOR_SPACING; uint160 sqrtRatioAX96 = TickMath.getSqrtRatioAtTick(tickLower); uint160 sqrtRatioBX96 = TickMath.getSqrtRatioAtTick(tickUpper); - uint256 discoveryAmount = pulledHarb * uint24(DISCOVERY_SPACING) * uint24(DISCOVERY_DEPTH) / uint24(ANCHOR_SPACING) / 100; + discoveryAmount = pulledHarb * uint24(DISCOVERY_SPACING) * uint24(DISCOVERY_DEPTH) / uint24(ANCHOR_SPACING) / 100; uint128 liquidity; if (token0isWeth) { liquidity = LiquidityAmounts.getLiquidityForAmount1( @@ -298,6 +299,8 @@ contract LiquidityManager { // set Floor position { outstandingSupply = harb.outstandingSupply(); + outstandingSupply -= pulledHarb; + outstandingSupply -= (outstandingSupply >= discoveryAmount) ? discoveryAmount : outstandingSupply; uint256 vwapX96 = 0; uint256 requiredEthForBuyback = 0; if (cumulativeVolume > 0) {