Skip to content

Commit

Permalink
Merge pull request #9 from ThenafiBNB/LowSeverity
Browse files Browse the repository at this point in the history
Low severity
  • Loading branch information
PrometeoThena committed Jun 15, 2023
2 parents 90412b6 + 0c37500 commit c62fb74
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 3 deletions.
13 changes: 12 additions & 1 deletion contracts/GaugeExtraRewarder.sol
Original file line number Diff line number Diff line change
Expand Up @@ -173,8 +173,19 @@ contract GaugeExtraRewarder is Ownable {
function recoverERC20(uint amount, address token) external onlyOwner {
require(amount > 0, "amount > 0");
require(token != address(0), "addr0");
require(IERC20(token).balanceOf(address(this)) >= amount, "not enough");
uint balance = IERC20(token).balanceOf(address(this));
require(balance >= amount, "not enough tokens");

// if token is = reward and there are some (rps > 0), allow withdraw only for remaining rewards and then set new rewPerSec
if(token == address(rewardToken) && rewardPerSecond != 0){
updatePool();
uint timeleft = lastDistributedTime - block.timestamp;
uint notDistributed = rewardPerSecond * timeleft;
require(amount <= notDistributed, 'too many rewardToken');
rewardPerSecond = (balance - amount) / timeleft;
}
IERC20(token).safeTransfer(msg.sender, amount);

}


Expand Down
5 changes: 3 additions & 2 deletions contracts/VoterV3.sol
Original file line number Diff line number Diff line change
Expand Up @@ -415,8 +415,9 @@ contract VoterV3 is OwnableUpgradeable, ReentrancyGuardUpgradeable {
uint256 _usedWeight = 0;
uint256 _time = _epochTimestamp();

for (uint256 i = 0; i < _poolCnt; i++) {
_totalVoteWeight += _weights[i];

for (uint i = 0; i < _poolCnt; i++) {
if(isAlive[gauges[_poolVote[i]]]) _totalVoteWeight += _weights[i];
}

for (uint256 i = 0; i < _poolCnt; i++) {
Expand Down

0 comments on commit c62fb74

Please sign in to comment.