From 5fc8dde13eeb0f5a2b7bb674784cb163f6b81909 Mon Sep 17 00:00:00 2001 From: toyvo Date: Mon, 27 Nov 2023 15:43:03 -0500 Subject: [PATCH] single distribute, 5.1 --- src/Voter.sol | 15 +++------------ src/test/PassthroughGauge.t.sol | 9 +-------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/Voter.sol b/src/Voter.sol index 482c721..8372cee 100644 --- a/src/Voter.sol +++ b/src/Voter.sol @@ -349,25 +349,16 @@ contract Voter is IVoter { /// @inheritdoc IVoter function distribute() external { - distribute(0, pools.length); - } + uint256 start = 0; + uint256 finish = pools.length; - function distribute(uint256 start, uint256 finish) public { for (uint256 x = start; x < finish; x++) { // We don't revert if gauge is not alive since pools.length is not reduced if (isAlive[gauges[pools[x]]]) { _distribute(gauges[pools[x]]); } } - IMinter(minter).updatePeriod(); - } - function distribute(address[] memory _gauges) external { - for (uint256 x = 0; x < _gauges.length; x++) { - // Only allow distribution to gauges that are alive - require(isAlive[_gauges[x]], "cannot distribute to a dead gauge"); - _distribute(_gauges[x]); - } IMinter(minter).updatePeriod(); } @@ -376,7 +367,7 @@ contract Voter is IVoter { */ function _distribute(address _gauge) internal { - // Distribute only once after epoch has ended + // Distribute once after epoch has ended require( block.timestamp >= IMinter(minter).activePeriod() + IMinter(minter).DURATION(), "can only distribute after period end" diff --git a/src/test/PassthroughGauge.t.sol b/src/test/PassthroughGauge.t.sol index ba3b787..eeaa3aa 100644 --- a/src/test/PassthroughGauge.t.sol +++ b/src/test/PassthroughGauge.t.sol @@ -50,16 +50,9 @@ contract PassthroughGaugeTest is BaseTest { // Claimable rewards of each gauge uint256 sushiGaugeClaimable = voter.claimable(address(sushiGauge)); - address[] memory deadGauges = new address[](1); - deadGauges[0] = address(0); - // Move forward epoch to distribute bribes hevm.warp(block.timestamp + nextEpoch); - - hevm.expectRevert(abi.encodePacked("cannot distribute to a dead gauge")); - voter.distribute(deadGauges); - - voter.distribute(gauges); + voter.distribute(); uint256 sushiBalanceAfter = alcx.balanceOf(sushiPoolAddress);