Closed sherlock-admin4 closed 4 months ago
Round Opal Kestrel
Low/Info
since votes is a unit and its if (_votes != 0) { then there is only one case that is _votes>0. _votes can never be less than 0.
function _reset(uint _tokenId) internal { address[] storage _poolVote = poolVote[_tokenId]; uint _poolVoteCnt = _poolVote.length; uint256 _totalWeight = 0;
for (uint i = 0; i < _poolVoteCnt; i ++) { address _pool = _poolVote[i]; uint256 _votes = votes[_tokenId][_pool]; if (_votes != 0) { _updateFor(gauges[_pool]); weights[_pool] -= _votes; votes[_tokenId][_pool] -= _votes; if (_votes > 0) { IBribe(external_bribes[gauges[_pool]])._withdraw(uint256(_votes), _tokenId); _totalWeight += _votes; } else { @>> _totalWeight -= _votes; } emit Abstained(_tokenId, _votes); } } totalWeight -= uint256(_totalWeight); usedWeights[_tokenId] = 0; delete poolVote[_tokenId]; }
it can cause code to be more efficient.
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/Voter.sol#L223
Manual Review
if (_votes != 0) { _updateFor(gauges[_pool]); weights[_pool] -= _votes; votes[_tokenId][_pool] -= _votes; if (_votes > 0) { IBribe(external_bribes[gauges[_pool]])._withdraw(uint256(_votes), _tokenId); _totalWeight += _votes; } emit Abstained(_tokenId, _votes); } }
Round Opal Kestrel
Low/Info
"_reset" function can be optimized.
Summary
since votes is a unit and its if (_votes != 0) { then there is only one case that is _votes>0. _votes can never be less than 0.
Vulnerability Detail
function _reset(uint _tokenId) internal { address[] storage _poolVote = poolVote[_tokenId]; uint _poolVoteCnt = _poolVote.length; uint256 _totalWeight = 0;
Impact
it can cause code to be more efficient.
Code Snippet
https://github.com/sherlock-audit/2024-06-velocimeter/blob/main/v4-contracts/contracts/Voter.sol#L223
Tool used
Manual Review
Recommendation