Skip to content

Commit

Permalink
feat: 1. delete bribe rewards; 2. delete isWhitelistedNFT & voting in…
Browse files Browse the repository at this point in the history
… Voter.sol; 3. update logic to distribute iotx;
  • Loading branch information
ludete committed Jun 24, 2024
1 parent 2c8116c commit bff629f
Show file tree
Hide file tree
Showing 11 changed files with 12 additions and 564 deletions.
2 changes: 1 addition & 1 deletion contracts/RewardsDistributor.sol
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ contract RewardsDistributor is IRewardsDistributor, ReentrancyGuard {
if (msg.sender != vault) revert NotVault();
uint256 _amount = msg.value;
if (_amount == 0) revert ZeroAmount();
strategyManager.distributeRewards{value: _amount}(_amount);
strategyManager.distributeRewards{value: _amount}(address(0x1), _amount);
}

/// @inheritdoc distribute rewards in erc20 format
Expand Down
190 changes: 0 additions & 190 deletions contracts/VeArtProxy.sol

This file was deleted.

28 changes: 6 additions & 22 deletions contracts/Voter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,8 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
address public governor;
/// @inheritdoc IVoter
address public emergencyCouncil;
/// @inheritdoc to control notify rewards in guage
address public team;

/// @inheritdoc IVoter
uint256 public totalWeight;
Expand All @@ -48,8 +50,6 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
/// @inheritdoc IVoter
mapping(address => address) public poolForGauge;
/// @inheritdoc IVoter
mapping(address => address) public gaugeToBribe;
/// @inheritdoc IVoter
mapping(address => uint256) public weights;
/// @inheritdoc IVoter
mapping(address => mapping(address => uint256)) public votes;
Expand Down Expand Up @@ -79,6 +79,7 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
address _sender = _msgSender();
vault = _sender;
governor = _sender;
team = _sender;
emergencyCouncil = _sender;
maxVotingNum = 30;
}
Expand Down Expand Up @@ -157,13 +158,10 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
_updateFor(gauges[_pool]);
weights[_pool] -= _votes;
delete votes[_user][_pool];
IReward(gaugeToBribe[gauges[_pool]])._withdraw(_votes, _user);
_totalWeight += _votes;
emit Abstained(_msgSender(), _pool, _votes, weights[_pool], block.timestamp);
}
}
// todo. yyx, need discuss how to reset vote in IStrategyManager
// IVotingEscrow(ve).voting(_user, false);
totalWeight -= _totalWeight;
usedWeights[_user] = 0;
delete poolVote[_user];
Expand Down Expand Up @@ -215,7 +213,6 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {

weights[_pool] += _poolWeight;
votes[_voter][_pool] += _poolWeight;
IReward(gaugeToBribe[_gauge])._deposit(_poolWeight, _voter);
_usedWeight += _poolWeight;
_totalWeight += _poolWeight;
emit Voted(_voter, _pool, _poolWeight, weights[_pool], block.timestamp);
Expand All @@ -234,9 +231,8 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
if (_poolVote.length != _weights.length) revert UnequalLengths();
if (_poolVote.length > maxVotingNum) revert TooManyPools();
uint256 _timestamp = block.timestamp;
// todo. yyx how to handler the condition
// if ((_timestamp > ProtocolTimeLibrary.epochVoteEnd(_timestamp)) && !isWhitelistedNFT[_tokenId])
// revert NotWhitelistedNFT();
if ((_timestamp > ProtocolTimeLibrary.epochVoteEnd(_timestamp)) )
revert NotWhitelistedNFT();
lastVoted[_voter] = _timestamp;
uint256 _weight = strategyManager.shares(_voter);
_vote(_voter, _weight, _poolVote, _weights);
Expand Down Expand Up @@ -265,19 +261,16 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
if (!isWhitelistedToken[_pool]) revert NotWhitelistedToken();
}

address _bribeVotingReward = IVotingRewardsFactory(votingRewardsFactory).createRewards(forwarder, _pool);

address _gauge = IGaugeFactory(gaugeFactory).createGauge(forwarder, _pool);

gaugeToBribe[_gauge] = _bribeVotingReward;
gauges[_pool] = _gauge;
poolForGauge[_gauge] = _pool;
isGauge[_gauge] = true;
isAlive[_gauge] = true;
_updateFor(_gauge);
pools.push(_pool);

emit GaugeCreated(_poolFactory, votingRewardsFactory, gaugeFactory, _pool, _bribeVotingReward, _gauge, sender);
emit GaugeCreated(_poolFactory, votingRewardsFactory, gaugeFactory, _pool, _gauge, sender);
return _gauge;
}

Expand Down Expand Up @@ -369,15 +362,6 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
}
}

/// @inheritdoc IVoter
function claimBribes(address[] memory _bribes, address[][] memory _tokens) external {
address _sender = msg.sender;
uint256 _length = _bribes.length;
for (uint256 i = 0; i < _length; i++) {
IReward(_bribes[i]).getReward(_sender, _tokens[i]);
}
}

function _distribute(address _gauge) internal {
_updateFor(_gauge); // should set claimable to 0 if killed
uint256 _claimable = claimable[_gauge];
Expand Down
7 changes: 1 addition & 6 deletions contracts/gauges/Gauge.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@
pragma solidity ^0.8.0;

import {Math} from "@openzeppelin/contracts/utils/math/Math.sol";
import {IReward} from "../interfaces/IReward.sol";
import {IGauge} from "../interfaces/IGauge.sol";
import {IVoter} from "../interfaces/IVoter.sol";
import {IVotingEscrow} from "../interfaces/IVotingEscrow.sol";
import {IERC20} from "@openzeppelin/contracts/token/ERC20/IERC20.sol";
import {SafeERC20} from "@openzeppelin/contracts/token/ERC20/utils/SafeERC20.sol";
import {ERC2771Context} from "@openzeppelin/contracts/metatx/ERC2771Context.sol";
Expand All @@ -22,8 +20,6 @@ contract Gauge is IGauge, ERC2771Context, ReentrancyGuard {
address public immutable stakingToken;
/// @inheritdoc IGauge
address public immutable voter;
/// @inheritdoc IGauge
address public immutable ve;

uint256 internal constant DURATION = 7 days; // rewards are released over 7 days
uint256 internal constant PRECISION = 10 ** 18;
Expand Down Expand Up @@ -153,8 +149,7 @@ contract Gauge is IGauge, ERC2771Context, ReentrancyGuard {
function notifyRewardWithoutClaim() external payable nonReentrant {
address sender = _msgSender();
uint256 _amount = msg.value;
// todo. yyx, whether to delete with IStrategyManager
// if (sender != IVotingEscrow(ve).team()) revert NotTeam();
if (sender != IVoter(voter).team()) revert NotTeam();
if (_amount == 0) revert ZeroAmount();
_notifyRewardAmount(sender, _amount);
}
Expand Down
2 changes: 0 additions & 2 deletions contracts/interfaces/IRewardsDistributor.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import {IVotingEscrow} from "./IVotingEscrow.sol";

interface IRewardsDistributor {

error NotVault();
Expand Down
11 changes: 2 additions & 9 deletions contracts/interfaces/IStrategyManager.sol
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
// SPDX-License-Identifier: MIT
pragma solidity ^0.8.0;

import "./IStrategy.sol";

interface IStrategyManager {

/**
Expand All @@ -11,12 +9,7 @@ interface IStrategyManager {
function shares(address user) external view returns (uint256);

/**
* @notice Distribute rewards with native token to strategyManager.
*/
function distributeRewards(uint256 amount) external payable;

/**
* @notice Distribute rewards with erc20 token to strategyManager.
* @notice Distribute rewards with erc20 or native iotx token to strategyManager.
*/
function distributeRewards(address token, uint256 amount) external returns(bool);
function distributeRewards(address token, uint256 amount) external payable returns(bool);
}
4 changes: 0 additions & 4 deletions contracts/interfaces/IVault.sol
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
pragma solidity ^0.8.0;

import {IVoter} from "./IVoter.sol";
import {IVotingEscrow} from "./IVotingEscrow.sol";
import {IRewardsDistributor} from "./IRewardsDistributor.sol";

interface IVault {
Expand All @@ -25,9 +24,6 @@ interface IVault {
/// @notice Standard OZ IGovernor using ve for vote weights.
function governor() external view returns (address);

/// @notice Interface of IVotingEscrow.sol
function ve() external view returns (IVotingEscrow);

/// @notice Interface of RewardsDistributor.sol
function rewardsDistributor() external view returns (IRewardsDistributor);

Expand Down
Loading

0 comments on commit bff629f

Please sign in to comment.