diff --git a/contracts/mixins/LiquidityMining.sol b/contracts/mixins/LiquidityMining.sol index c0a7c5f5..d89e7165 100644 --- a/contracts/mixins/LiquidityMining.sol +++ b/contracts/mixins/LiquidityMining.sol @@ -201,20 +201,18 @@ contract LiquidityMining is PositionRegistrar { for (uint256 i; i < weeksToClaim.length; ++i) { uint32 week = weeksToClaim[i]; require(week + WEEK < block.timestamp, "Week not over yet"); - require( - !concLiquidityRewardsClaimed_[poolIdx][posKey][week], - "Already claimed" - ); - uint256 overallInRangeLiquidity = timeWeightedWeeklyGlobalConcLiquidity_[poolIdx][week]; - if (overallInRangeLiquidity > 0) { - uint256 inRangeLiquidityOfPosition; - for (int24 j = lowerTick + 100; j <= upperTick - 100; ++j) { - inRangeLiquidityOfPosition += timeWeightedWeeklyPositionInRangeConcLiquidity_[poolIdx][posKey][week][j]; + if (!concLiquidityRewardsClaimed_[poolIdx][posKey][week]) { + uint256 overallInRangeLiquidity = timeWeightedWeeklyGlobalConcLiquidity_[poolIdx][week]; + if (overallInRangeLiquidity > 0) { + uint256 inRangeLiquidityOfPosition; + for (int24 j = lowerTick + 100; j <= upperTick - 100; ++j) { + inRangeLiquidityOfPosition += timeWeightedWeeklyPositionInRangeConcLiquidity_[poolIdx][posKey][week][j]; + } + // Percentage of this weeks overall in range liquidity that was provided by the user times the overall weekly rewards + rewardsToSend += inRangeLiquidityOfPosition * concRewardPerWeek_[poolIdx][week] / overallInRangeLiquidity; } - // Percentage of this weeks overall in range liquidity that was provided by the user times the overall weekly rewards - rewardsToSend += inRangeLiquidityOfPosition * concRewardPerWeek_[poolIdx][week] / overallInRangeLiquidity; + concLiquidityRewardsClaimed_[poolIdx][posKey][week] = true; } - concLiquidityRewardsClaimed_[poolIdx][posKey][week] = true; } if (rewardsToSend > 0) { (bool sent, ) = owner.call{value: rewardsToSend}("");