Skip to content

Commit

Permalink
add adhoc gauge
Browse files Browse the repository at this point in the history
  • Loading branch information
CoderZhi committed Aug 9, 2024
1 parent 2876243 commit 3ac4991
Showing 1 changed file with 17 additions and 3 deletions.
20 changes: 17 additions & 3 deletions contracts/Voter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -280,15 +280,29 @@ contract Voter is IVoter, ERC2771Context, ReentrancyGuard {
address _gauge = IGaugeFactory(gaugeFactory).createGauge(forwarder, _pool, _incentiveReward, _gaugeType);
IIncentive(_incentiveReward).setGauge(_gauge);

_addGauge(_pool, _gauge);

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

function addGauge(address _pool, address _gauge) external nonReentrant {
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);

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

/// @inheritdoc IVoter
Expand Down

0 comments on commit 3ac4991

Please sign in to comment.