Skip to content

Commit f5fa1f6

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

File tree

1 file changed

+9
-10
lines changed

1 file changed

+9
-10
lines changed

contracts/bonding/BondingManager.sol

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

473-
if (nextRoundTreasuryRewardCutRate != treasuryRewardCutRate) {
473+
// Set the treasury cut to 0 while the treasury balance is above the ceiling
474+
uint256 treasuryBalance = livepeerToken().balanceOf(treasury());
475+
if (treasuryBalanceCeiling > 0 && treasuryBalance >= treasuryBalanceCeiling) {
476+
if (treasuryRewardCutRate > 0) {
477+
treasuryRewardCutRate = 0;
478+
emit ParameterUpdate("treasuryRewardCutRate");
479+
}
480+
} else if (nextRoundTreasuryRewardCutRate != treasuryRewardCutRate) {
481+
// Reset to the desired treasury cut rate
474482
treasuryRewardCutRate = nextRoundTreasuryRewardCutRate;
475-
// The treasury cut rate changes in a delayed fashion so we want to emit the parameter update event here
476483
emit ParameterUpdate("treasuryRewardCutRate");
477484
}
478485

@@ -890,14 +897,6 @@ contract BondingManager is ManagerProxyTarget, IBondingManager {
890897
earningsPool.setStake(t.earningsPoolPerRound[lastUpdateRound].totalStake);
891898
}
892899

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-
901900
// Create reward based on active transcoder's stake relative to the total active stake
902901
// rewardTokens = (current mintable tokens for the round * active transcoder stake) / total active stake
903902
IMinter mtr = minter();

0 commit comments

Comments
 (0)