Platform: Code4rena
Start Date: 30/05/2023
Pot Size: $300,500 USDC
Total HM: 79
Participants: 101
Period: about 1 month
Judge: Trust
Total Solo HM: 36
Id: 242
League: ETH
Rank: 54/101
Findings: 1
Award: $240.03
🌟 Selected for report: 0
🚀 Solo Findings: 0
240.0331 USDC - $240.03
https://github.com/code-423n4/2023-05-maia/blob/main/src/erc-20/ERC20Gauges.sol#L519-L555
In _decrementWeightUntilFree
, the free weight is calculated by freeVotes(user) + userUnusedVotes(user)
plus weight freed from non-deprecated gauges. The non-deprecated criteria is unnecessary and lead to incorrect accounting of free weight.
Consider Alice allocated 3 weight to gauge D, gauge A and gauge B equally where gauge D is deprecated
Alternatively, Alice can
function _decrementWeightUntilFree(address user, uint256 weight) internal nonReentrant { uint256 userFreeWeight = freeVotes(user) + userUnusedVotes(user); // early return if already free if (userFreeWeight >= weight) return; uint32 currentCycle = _getGaugeCycleEnd(); // cache totals for batch updates uint112 userFreed; uint112 totalFreed; // Loop through all user gauges, live and deprecated address[] memory gaugeList = _userGauges[user].values(); // Free gauges through the entire list or until underweight uint256 size = gaugeList.length; for (uint256 i = 0; i < size && (userFreeWeight + totalFreed) < weight;) { address gauge = gaugeList[i]; uint112 userGaugeWeight = getUserGaugeWeight[user][gauge]; if (userGaugeWeight != 0) { // If the gauge is live (not deprecated), include its weight in the total to remove if (!_deprecatedGauges.contains(gauge)) { totalFreed += userGaugeWeight; } userFreed += userGaugeWeight; _decrementGaugeWeight(user, gauge, userGaugeWeight, currentCycle); unchecked { i++; } } } getUserWeight[user] -= userFreed; _writeGaugeWeight(_totalWeight, _subtract112, totalFreed, currentCycle); }
Foundry
No need to treat deprecated gauge seperately
Other
#0 - c4-judge
2023-07-10T14:35:22Z
trust1995 marked the issue as satisfactory
#1 - c4-judge
2023-07-10T14:36:54Z
trust1995 marked the issue as primary issue
#2 - c4-judge
2023-07-11T09:44:08Z
trust1995 marked the issue as duplicate of #477