Skip to content

Commit e55109a

Browse files
committed
Ensure the treasury automatically resumes once balance < cap
1 parent e8b6243 commit e55109a

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

contracts/bonding/BondingManager.sol

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -470,12 +470,21 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
470470
function setCurrentRoundTotalActiveStake() external onlyRoundsManager {
471471
currentRoundTotalActiveStake = nextRoundTotalActiveStake;
472472

473+
// Apply any queued changes to the treasury cut
473474
if (nextRoundTreasuryRewardCutRate != treasuryRewardCutRate) {
474475
treasuryRewardCutRate = nextRoundTreasuryRewardCutRate;
475476
// The treasury cut rate changes in a delayed fashion so we want to emit the parameter update event here
476477
emit ParameterUpdate("treasuryRewardCutRate");
477478
}
478479

480+
// Set the treasury cut to 0 while the treasury balance is above the ceiling
481+
if (treasuryBalanceCeiling > 0) {
482+
uint256 treasuryBalance = livepeerToken().balanceOf(treasury());
483+
if (treasuryBalance >= treasuryBalanceCeiling && treasuryRewardCutRate > 0) {
484+
treasuryRewardCutRate = 0;
485+
}
486+
}
487+
479488
bondingVotes().checkpointTotalActiveStake(currentRoundTotalActiveStake, roundsManager().currentRound());
480489
}
481490

@@ -890,14 +899,6 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
890899
earningsPool.setStake(t.earningsPoolPerRound[lastUpdateRound].totalStake);
891900
}
892901

893-
if (treasuryBalanceCeiling > 0) {
894-
uint256 treasuryBalance = livepeerToken().balanceOf(treasury());
895-
if (treasuryBalance >= treasuryBalanceCeiling && nextRoundTreasuryRewardCutRate > 0) {
896-
// halt treasury contributions until the cut rate param is updated again
897-
_setTreasuryRewardCutRate(0);
898-
}
899-
}
900-
901902
// Create reward based on active transcoder's stake relative to the total active stake
902903
// rewardTokens = (current mintable tokens for the round * active transcoder stake) / total active stake
903904
IMinter mtr = minter();

0 commit comments

Comments
 (0)