Platform: Code4rena
Start Date: 03/10/2023
Pot Size: $24,500 USDC
Total HM: 6
Participants: 62
Period: 3 days
Judge: LSDan
Total Solo HM: 3
Id: 288
League: ETH
Rank: 59/62
Findings: 1
Award: $4.94
🌟 Selected for report: 0
🚀 Solo Findings: 0
🌟 Selected for report: adriro
Also found by: 0x3b, 0xAadi, 0xDING99YA, 0xTheC0der, 0xWaitress, 0xdice91, 100su, 3docSec, BRONZEDISC, BoRonGod, Eurovickk, GKBG, HChang26, IceBear, JP_Courses, MatricksDeCoder, Mike_Bello90, SovaSlava, Topmark, albahaca, cookedcookee, gzeon, hunter_w3b, kutugu, lukejohn, marqymarq10, matrix_0wl, orion, pep7siup, radev_sw, sces60107, taner2344, tpiliposian, wahedtalash77, xAriextz, zpan
4.9369 USDC - $4.94
In LiquidityMiningPath.sol
,
require(weekFrom % WEEK == 0 && weekTo % WEEK == 0, "Invalid weeks");
is updated to
require(weekFrom % WEEK == 0 && weekTo % WEEK == 0 && weekFrom <= weekTo, "Invalid weeks");
in order to let users know that those are invalid weeks.
In LiquidityMining.sol
,
overallInRangeLiquidity
is zero.if (overallInRangeLiquidity == 0) continue;
uint256 overallInRangeLiquidity = timeWeightedWeeklyGlobalConcLiquidity_[poolIdx][week]; if (overallInRangeLiquidity == 0) { continue; } uint256 inRangeLiquidityOfPosition; for (int24 j = lowerTick + 10; j <= upperTick - 10; ++j) { inRangeLiquidityOfPosition += timeWeightedWeeklyPositionInRangeConcLiquidity_[poolIdx][posKey][week][j]; }
overallInRangeLiquidity
can be checked first before calculation of inRangeLiquidityOfPosition
.In main
branch, it seems to be resolved, but a line can be also fixed as above or the following.
uint256 overallInRangeLiquidity = timeWeightedWeeklyGlobalConcLiquidity_[poolIdx][week]; if (overallInRangeLiquidity > 0) { uint256 inRangeLiquidityOfPosition; for (int24 j = lowerTick + 10; j <= upperTick - 10; ++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; concLiquidityRewardsClaimed_[poolIdx][posKey][week] = true; }
concLiquidityRewardsClaimed_[poolIdx][posKey][week] = true;
is moved into if-loop in order to save gas.In LiquidityMining.sol
,
liquidity == 0
, there is no meaning the codes below the line. So, the following revision is recommended to change from// Only set time on first call if (lastAccrued != 0) { uint256 liquidity = curve.concLiq_;
to
// Only set time on first call uint256 liquidity = curve.concLiq_; if (lastAccrued != 0 && liquidity != 0) {
Currently, the liquidity mining mechanism considers the rewards only with native canto. Canto already deployed wcanto ERC20 contracts and it has been used. In this regards, if the rewards of the liquidity mining mechanism is distributed by wcanto (ERC20), the mechanism can be easily generalized with other rewards of other ERC20 tokens in the future. Of course, for this generalization, some more functions need to be developed, e.g., registration of rewards with amount and contracts, support of multiple tokens for rewards, and so on.
#0 - c4-pre-sort
2023-10-09T17:22:45Z
141345 marked the issue as sufficient quality report
#1 - c4-judge
2023-10-18T22:45:31Z
dmvt marked the issue as grade-b