From 3ac4991baa7a4e55977886313fb2ac68687bdb2f Mon Sep 17 00:00:00 2001 From: zhi Date: Sat, 10 Aug 2024 01:02:20 +0800 Subject: [PATCH] add adhoc gauge --- contracts/Voter.sol | 20 +++++++++++++++++--- 1 file changed, 17 insertions(+), 3 deletions(-) diff --git a/contracts/Voter.sol b/contracts/Voter.sol index b86fa81..cfe4197 100644 --- a/contracts/Voter.sol +++ b/contracts/Voter.sol @@ -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