@@ -10,6 +10,7 @@ import (
1010 "github.com/Layr-Labs/eigenlayer-cli/pkg/utils"
1111
1212 "github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts"
13+ contractIAllocationManager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IAllocationManager"
1314 "github.com/Layr-Labs/eigensdk-go/logging"
1415 eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils"
1516
@@ -52,7 +53,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
5253 }
5354
5455 // Temp to test modify allocations
55- config .delegationManagerAddress = gethcommon .HexToAddress ("0xec91e43612896E7D45736cE751bea6dbf1BBEdB5 " )
56+ config .delegationManagerAddress = gethcommon .HexToAddress ("0x1a597729A7dCfeDDD1f6130fBb099892B7623FAd " )
5657
5758 elReader , err := elcontracts .NewReaderFromConfig (
5859 elcontracts.Config {
@@ -75,7 +76,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
7576 if err != nil {
7677 return eigenSdkUtils .WrapError ("failed to get allocatable magnitude" , err )
7778 }
78- logger .Debugf ("Allocatable magnitude for strategy %v: %d " , strategyAddress , allocatableMagnitude )
79+ logger .Debugf ("Allocatable magnitude for strategy %v: %s " , strategyAddress , common . FormatNumberWithUnderscores ( allocatableMagnitude ) )
7980 }
8081
8182 opSets , slashableMagnitudes , err := elReader .GetCurrentSlashableMagnitudes (
@@ -87,21 +88,9 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
8788 return eigenSdkUtils .WrapError ("failed to get slashable magnitude" , err )
8889 }
8990
90- slashableMagnitudeHolders := make (SlashableMagnitudeHolders , 0 )
91- for i , strategyAddress := range config .strategyAddresses {
92- slashableMagnitude := slashableMagnitudes [i ]
93- for j , opSet := range opSets {
94- slashableMagnitudeHolders = append (slashableMagnitudeHolders , SlashableMagnitudesHolder {
95- StrategyAddress : strategyAddress ,
96- AVSAddress : opSet .Avs ,
97- OperatorSetId : opSet .OperatorSetId ,
98- SlashableMagnitude : slashableMagnitude [j ],
99- })
100- }
101- }
102-
10391 // Get Pending allocations
104- pendingAllocationsDetails := make (AllocationDetailsHolder , 0 )
92+ //pendingAllocationsDetails := make(AllocationDetailsHolder, 0)
93+ pendingAllocationMap := make (map [string ]AllocDetails )
10594 for _ , strategyAddress := range config .strategyAddresses {
10695 pendingAllocations , timestamps , err := elReader .GetPendingAllocations (
10796 & bind.CallOpts {Context : ctx },
@@ -118,17 +107,22 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
118107 if pendingAllocation == 0 && timestamp == 0 {
119108 continue
120109 }
121- pendingAllocationsDetails = append (pendingAllocationsDetails , AllocationDetails {
122- StrategyAddress : strategyAddress ,
123- AVSAddress : opSet .Avs ,
124- OperatorSetId : opSet .OperatorSetId ,
125- Allocation : pendingAllocation ,
126- Timestamp : timestamp ,
127- })
110+ //pendingAllocationsDetails = append(pendingAllocationsDetails, AllocationDetails{
111+ // StrategyAddress: strategyAddress,
112+ // AVSAddress: opSet.Avs,
113+ // OperatorSetId: opSet.OperatorSetId,
114+ // Allocation: pendingAllocation,
115+ // Timestamp: timestamp,
116+ //})
117+ pendingAllocationMap [getUniqueKey (strategyAddress , opSet )] = AllocDetails {
118+ Magnitude : pendingAllocation ,
119+ Timestamp : timestamp ,
120+ }
128121 }
129122 }
130123
131- pendingDeallocationsDetails := make (AllocationDetailsHolder , 0 )
124+ //pendingDeallocationsDetails := make(AllocationDetailsHolder, 0)
125+ pendingdeAllocationMap := make (map [string ]AllocDetails )
132126 for _ , strategyAddress := range config .strategyAddresses {
133127 pendingDeallocations , err := elReader .GetPendingDeallocations (
134128 & bind.CallOpts {Context : ctx },
@@ -144,33 +138,67 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
144138 if pendingAllocation .MagnitudeDiff == 0 && pendingAllocation .CompletableTimestamp == 0 {
145139 continue
146140 }
147- pendingDeallocationsDetails = append (pendingDeallocationsDetails , AllocationDetails {
148- StrategyAddress : strategyAddress ,
149- AVSAddress : opSet .Avs ,
150- OperatorSetId : opSet .OperatorSetId ,
151- Allocation : pendingAllocation .MagnitudeDiff ,
152- Timestamp : pendingAllocation .CompletableTimestamp ,
153- })
141+ //pendingDeallocationsDetails = append(pendingDeallocationsDetails, AllocationDetails{
142+ // StrategyAddress: strategyAddress,
143+ // AVSAddress: opSet.Avs,
144+ // OperatorSetId: opSet.OperatorSetId,
145+ // Allocation: pendingAllocation.MagnitudeDiff,
146+ // Timestamp: pendingAllocation.CompletableTimestamp,
147+ //})
148+ pendingdeAllocationMap [getUniqueKey (strategyAddress , opSet )] = AllocDetails {
149+ Magnitude : pendingAllocation .MagnitudeDiff ,
150+ Timestamp : pendingAllocation .CompletableTimestamp ,
151+ }
154152 }
155153 }
156154
157- fmt .Println ()
158- fmt .Println ("------------------Pending Allocations---------------------" )
159- if config .outputType == string (common .OutputType_Json ) {
160- pendingAllocationsDetails .PrintJSON ()
161- } else {
162- pendingAllocationsDetails .PrintPretty ()
163- }
164- fmt .Println ()
155+ slashableMagnitudeHolders := make (SlashableMagnitudeHolders , 0 )
156+ for i , strategyAddress := range config .strategyAddresses {
157+ slashableMagnitude := slashableMagnitudes [i ]
158+ for j , opSet := range opSets {
159+ newAllocation := uint64 (0 )
160+ newTimestamp := uint32 (0 )
161+ currSlashableMag := slashableMagnitude [j ]
162+ someKey := getUniqueKey (strategyAddress , opSet )
163+ if _ , ok := pendingAllocationMap [someKey ]; ok {
164+ newAllocation = pendingAllocationMap [someKey ].Magnitude
165+ newTimestamp = pendingAllocationMap [someKey ].Timestamp
166+ }
165167
166- fmt .Println ()
167- fmt .Println ("------------------Pending Deallocations---------------------" )
168- if config .outputType == string (common .OutputType_Json ) {
169- pendingDeallocationsDetails .PrintJSON ()
170- } else {
171- pendingDeallocationsDetails .PrintPretty ()
168+ if _ , ok := pendingdeAllocationMap [someKey ]; ok {
169+ newAllocationDiff := pendingdeAllocationMap [someKey ].Magnitude
170+ newTimestamp = pendingdeAllocationMap [someKey ].Timestamp
171+ newAllocation = currSlashableMag
172+ currSlashableMag = currSlashableMag + newAllocationDiff
173+ }
174+ slashableMagnitudeHolders = append (slashableMagnitudeHolders , SlashableMagnitudesHolder {
175+ StrategyAddress : strategyAddress ,
176+ AVSAddress : opSet .Avs ,
177+ OperatorSetId : opSet .OperatorSetId ,
178+ SlashableMagnitude : currSlashableMag ,
179+ NewMagnitude : newAllocation ,
180+ NewMagnitudeTimestamp : newTimestamp ,
181+ })
182+ }
172183 }
184+
173185 fmt .Println ()
186+ //fmt.Println("------------------Pending Allocations---------------------")
187+ //if config.outputType == string(common.OutputType_Json) {
188+ // pendingAllocationsDetails.PrintJSON()
189+ //} else {
190+ // pendingAllocationsDetails.PrintPretty()
191+ //}
192+ //fmt.Println()
193+ //
194+ //fmt.Println()
195+ //fmt.Println("------------------Pending Deallocations---------------------")
196+ //if config.outputType == string(common.OutputType_Json) {
197+ // pendingDeallocationsDetails.PrintJSON()
198+ //} else {
199+ // pendingDeallocationsDetails.PrintPretty()
200+ //}
201+ //fmt.Println()
174202
175203 fmt .Println ("------------------Current Slashable Magnitudes---------------------" )
176204 if config .outputType == string (common .OutputType_Json ) {
@@ -182,6 +210,10 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
182210 return nil
183211}
184212
213+ func getUniqueKey (strategyAddress gethcommon.Address , opSet contractIAllocationManager.OperatorSet ) string {
214+ return fmt .Sprintf ("%s-%s-%d" , strategyAddress .String (), opSet .Avs .String (), opSet .OperatorSetId )
215+ }
216+
185217func readAndValidateShowConfig (cCtx * cli.Context , logger * logging.Logger ) (* showConfig , error ) {
186218 network := cCtx .String (flags .NetworkFlag .Name )
187219 rpcUrl := cCtx .String (flags .ETHRpcUrlFlag .Name )
0 commit comments