Skip to content

Commit

Permalink
fix: remove 0 total strategy
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Dec 18, 2024
1 parent 34d9897 commit 3b1497c
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions pkg/operator/allocations/show.go
Original file line number Diff line number Diff line change
Expand Up @@ -166,15 +166,15 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
dergisteredOpsets := make(DeregsiteredOperatorSets, 0)
for strategy, allocations := range allAllocations {
logger.Debugf("Strategy: %s, Allocations: %v", strategy, allocations)
strategyShares := operatorDelegatedSharesMap[strategy]
totalStrategyShares := operatorDelegatedSharesMap[strategy]
totalMagnitude := totalMagnitudeMap[strategy]
for _, alloc := range allocations {

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

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

newMagnitudeBigInt := big.NewInt(0)
if alloc.PendingDiff.Cmp(big.NewInt(0)) != 0 {
newMagnitudeBigInt = big.NewInt(0).Add(alloc.CurrentMagnitude, alloc.PendingDiff)
}

newShares, newSharesPercentage := getSharesFromMagnitude(
strategyShares,
totalStrategyShares,
newMagnitudeBigInt.Uint64(),
totalMagnitude,
)
Expand Down

0 comments on commit 3b1497c

Please sign in to comment.