Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add adhoc gauge to voter manually #17

Open
wants to merge 2 commits into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 17 additions & 4 deletions contracts/Voter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -291,16 +291,29 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
address _gauge = IGaugeFactory(gaugeFactory).createGauge(forwarder, _pool, _incentiveReward, _gaugeType, threshold);
IIncentive(_incentiveReward).setGauge(_gauge);

_addGauge(_pool, _gauge);

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

function addGauge(address _pool, address _gauge) external nonReentrant {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nonReentrant not need.

address sender = _msgSender();
if (sender != governor) revert NotGovernor();
if (gauges[_pool] != address(0)) revert GaugeExists();

_addGauge(_pool, _gauge);

emit GaugeCreated(address(0), address(0), _pool, _gauge, sender);
}

function _addGauge(address _pool, address _gauge) internal {
gauges[_pool] = _gauge;
poolForGauge[_gauge] = _pool;
isGauge[_gauge] = true;
isAlive[_gauge] = true;
_updateFor(_gauge);
pools.push(_pool);
triggerThreshold[_gauge] = threshold;

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

/// @inheritdoc IVoter
Expand Down
Loading