Skip to content

Commit 3b1497c

Browse files
committed
fix: remove 0 total strategy
1 parent 34d9897 commit 3b1497c

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

pkg/operator/allocations/show.go

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -166,15 +166,15 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
166166
dergisteredOpsets := make(DeregsiteredOperatorSets, 0)
167167
for strategy, allocations := range allAllocations {
168168
logger.Debugf("Strategy: %s, Allocations: %v", strategy, allocations)
169-
strategyShares := operatorDelegatedSharesMap[strategy]
169+
totalStrategyShares := operatorDelegatedSharesMap[strategy]
170170
totalMagnitude := totalMagnitudeMap[strategy]
171171
for _, alloc := range allocations {
172172

173173
// Check if the operator set is not registered and add it to the unregistered list
174174
// Then skip the rest of the loop
175175
if _, ok := registeredOperatorSetsMap[getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]; !ok {
176176
currentShares, currentSharesPercentage := getSharesFromMagnitude(
177-
strategyShares,
177+
totalStrategyShares,
178178
alloc.CurrentMagnitude.Uint64(),
179179
totalMagnitude,
180180
)
@@ -199,16 +199,20 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
199199
continue
200200
}
201201

202+
// If the total shares in that strategy are zero, skip the operator set
203+
if totalStrategyShares == nil || totalStrategyShares.Cmp(big.NewInt(0)) == 0 {
204+
continue
205+
}
202206
currentShares := slashableSharesMap[gethcommon.HexToAddress(strategy)][getUniqueKey(alloc.AvsAddress, alloc.OperatorSetId)]
203-
currentSharesPercentage := getSharePercentage(currentShares, strategyShares)
207+
currentSharesPercentage := getSharePercentage(currentShares, totalStrategyShares)
204208

205209
newMagnitudeBigInt := big.NewInt(0)
206210
if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 {
207211
newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff)
208212
}
209213

210214
newShares, newSharesPercentage := getSharesFromMagnitude(
211-
strategyShares,
215+
totalStrategyShares,
212216
newMagnitudeBigInt.Uint64(),
213217
totalMagnitude,
214218
)

0 commit comments

Comments
 (0)