@@ -10,6 +10,7 @@ import (
10
10
"github.com/Layr-Labs/eigenlayer-cli/pkg/utils"
11
11
12
12
"github.com/Layr-Labs/eigensdk-go/chainio/clients/elcontracts"
13
+ contractIAllocationManager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/IAllocationManager"
13
14
"github.com/Layr-Labs/eigensdk-go/logging"
14
15
eigenSdkUtils "github.com/Layr-Labs/eigensdk-go/utils"
15
16
@@ -52,7 +53,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
52
53
}
53
54
54
55
// Temp to test modify allocations
55
- config .delegationManagerAddress = gethcommon .HexToAddress ("0xec91e43612896E7D45736cE751bea6dbf1BBEdB5 " )
56
+ config .delegationManagerAddress = gethcommon .HexToAddress ("0x1a597729A7dCfeDDD1f6130fBb099892B7623FAd " )
56
57
57
58
elReader , err := elcontracts .NewReaderFromConfig (
58
59
elcontracts.Config {
@@ -75,7 +76,7 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
75
76
if err != nil {
76
77
return eigenSdkUtils .WrapError ("failed to get allocatable magnitude" , err )
77
78
}
78
- logger .Debugf ("Allocatable magnitude for strategy %v: %d " , strategyAddress , allocatableMagnitude )
79
+ logger .Debugf ("Allocatable magnitude for strategy %v: %s " , strategyAddress , common . FormatNumberWithUnderscores ( allocatableMagnitude ) )
79
80
}
80
81
81
82
opSets , slashableMagnitudes , err := elReader .GetCurrentSlashableMagnitudes (
@@ -87,21 +88,9 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
87
88
return eigenSdkUtils .WrapError ("failed to get slashable magnitude" , err )
88
89
}
89
90
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
-
103
91
// Get Pending allocations
104
- pendingAllocationsDetails := make (AllocationDetailsHolder , 0 )
92
+ //pendingAllocationsDetails := make(AllocationDetailsHolder, 0)
93
+ pendingAllocationMap := make (map [string ]AllocDetails )
105
94
for _ , strategyAddress := range config .strategyAddresses {
106
95
pendingAllocations , timestamps , err := elReader .GetPendingAllocations (
107
96
& bind.CallOpts {Context : ctx },
@@ -118,17 +107,22 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
118
107
if pendingAllocation == 0 && timestamp == 0 {
119
108
continue
120
109
}
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
+ }
128
121
}
129
122
}
130
123
131
- pendingDeallocationsDetails := make (AllocationDetailsHolder , 0 )
124
+ //pendingDeallocationsDetails := make(AllocationDetailsHolder, 0)
125
+ pendingdeAllocationMap := make (map [string ]AllocDetails )
132
126
for _ , strategyAddress := range config .strategyAddresses {
133
127
pendingDeallocations , err := elReader .GetPendingDeallocations (
134
128
& bind.CallOpts {Context : ctx },
@@ -144,33 +138,67 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
144
138
if pendingAllocation .MagnitudeDiff == 0 && pendingAllocation .CompletableTimestamp == 0 {
145
139
continue
146
140
}
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
+ }
154
152
}
155
153
}
156
154
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
+ }
165
167
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
+ }
172
183
}
184
+
173
185
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()
174
202
175
203
fmt .Println ("------------------Current Slashable Magnitudes---------------------" )
176
204
if config .outputType == string (common .OutputType_Json ) {
@@ -182,6 +210,10 @@ func showAction(cCtx *cli.Context, p utils.Prompter) error {
182
210
return nil
183
211
}
184
212
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
+
185
217
func readAndValidateShowConfig (cCtx * cli.Context , logger * logging.Logger ) (* showConfig , error ) {
186
218
network := cCtx .String (flags .NetworkFlag .Name )
187
219
rpcUrl := cCtx .String (flags .ETHRpcUrlFlag .Name )
0 commit comments