From f5fa1f64d6d56159ef032b0190a87296d504f826 Mon Sep 17 00:00:00 2001 From: Marco van Dijk Date: Wed, 2 Apr 2025 16:36:04 +0200 Subject: [PATCH] Ensure the treasury automatically resumes once balance < cap --- contracts/bonding/BondingManager.sol | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/contracts/bonding/BondingManager.sol b/contracts/bonding/BondingManager.sol index c401324b..6c531293 100644 --- a/contracts/bonding/BondingManager.sol +++ b/contracts/bonding/BondingManager.sol @@ -470,9 +470,16 @@ contract BondingManager is ManagerProxyTarget, IBondingManager { function setCurrentRoundTotalActiveStake() external onlyRoundsManager { currentRoundTotalActiveStake = nextRoundTotalActiveStake; - if (nextRoundTreasuryRewardCutRate != treasuryRewardCutRate) { + // Set the treasury cut to 0 while the treasury balance is above the ceiling + uint256 treasuryBalance = livepeerToken().balanceOf(treasury()); + if (treasuryBalanceCeiling > 0 && treasuryBalance >= treasuryBalanceCeiling) { + if (treasuryRewardCutRate > 0) { + treasuryRewardCutRate = 0; + emit ParameterUpdate("treasuryRewardCutRate"); + } + } else if (nextRoundTreasuryRewardCutRate != treasuryRewardCutRate) { + // Reset to the desired treasury cut rate treasuryRewardCutRate = nextRoundTreasuryRewardCutRate; - // The treasury cut rate changes in a delayed fashion so we want to emit the parameter update event here emit ParameterUpdate("treasuryRewardCutRate"); } @@ -890,14 +897,6 @@ contract BondingManager is ManagerProxyTarget, IBondingManager { earningsPool.setStake(t.earningsPoolPerRound[lastUpdateRound].totalStake); } - if (treasuryBalanceCeiling > 0) { - uint256 treasuryBalance = livepeerToken().balanceOf(treasury()); - if (treasuryBalance >= treasuryBalanceCeiling && nextRoundTreasuryRewardCutRate > 0) { - // halt treasury contributions until the cut rate param is updated again - _setTreasuryRewardCutRate(0); - } - } - // Create reward based on active transcoder's stake relative to the total active stake // rewardTokens = (current mintable tokens for the round * active transcoder stake) / total active stake IMinter mtr = minter();