Skip to content

Commit

Permalink
single distribute, 5.1
Browse files Browse the repository at this point in the history
  • Loading branch information
toyv0 committed Nov 27, 2023
1 parent 05d4325 commit 5fc8dde
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 20 deletions.
15 changes: 3 additions & 12 deletions src/Voter.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}

Expand All @@ -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"
Expand Down
9 changes: 1 addition & 8 deletions src/test/PassthroughGauge.t.sol
Original file line number Diff line number Diff line change
Expand Up @@ -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);

Expand Down

0 comments on commit 5fc8dde

Please sign in to comment.