From b6673ab0c46673e977ba008ead39620a3680fc54 Mon Sep 17 00:00:00 2001 From: wadealexc Date: Fri, 14 Feb 2025 17:23:27 +0000 Subject: [PATCH] feat: dont call strategy if we have no burnable shares --- docs/core/StrategyManager.md | 2 ++ src/contracts/core/StrategyManager.sol | 8 ++++++-- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/docs/core/StrategyManager.md b/docs/core/StrategyManager.md index ddb817dbd5..34e4d8797d 100644 --- a/docs/core/StrategyManager.md +++ b/docs/core/StrategyManager.md @@ -298,6 +298,8 @@ function burnShares( Anyone can call this method to burn slashed shares previously added by the `DelegationManager` via `increaseBurnableShares`. This method resets the strategy's burnable shares to 0, and directs the corresponding `strategy` to convert the shares to tokens and transfer them to `DEFAULT_BURN_ADDRESS`, rendering them unrecoverable. +The `strategy` is not called if the strategy had no burnable shares. + *Effects*: * Resets the strategy's burnable shares to 0 * Calls `withdraw` on the `strategy`, withdrawing shares and sending a corresponding amount of tokens to the `DEFAULT_BURN_ADDRESS` diff --git a/src/contracts/core/StrategyManager.sol b/src/contracts/core/StrategyManager.sol index 49ed6c5e87..6741911f28 100644 --- a/src/contracts/core/StrategyManager.sol +++ b/src/contracts/core/StrategyManager.sol @@ -154,8 +154,12 @@ contract StrategyManager is (, uint256 sharesToBurn) = EnumerableMap.tryGet(burnableShares, address(strategy)); EnumerableMap.remove(burnableShares, address(strategy)); emit BurnableSharesDecreased(strategy, sharesToBurn); - // burning shares is functionally the same as withdrawing but with different destination address - strategy.withdraw(DEFAULT_BURN_ADDRESS, strategy.underlyingToken(), sharesToBurn); + + // Burning acts like withdrawing, except that the destination is to the burn address. + // If we have no shares to burn, we don't need to call the strategy. + if (sharesToBurn != 0) { + strategy.withdraw(DEFAULT_BURN_ADDRESS, strategy.underlyingToken(), sharesToBurn); + } } /// @inheritdoc IStrategyManager