99 "sort"
1010 "sync"
1111
12- "github.com/ethereum/go-ethereum/accounts/abi/bind"
1312 gethcommon "github.com/ethereum/go-ethereum/common"
1413 "github.com/ethereum/go-ethereum/ethclient"
1514
@@ -29,12 +28,12 @@ import (
2928
3029type elChainReader interface {
3130 GetMaxMagnitudes (
32- opts * bind. CallOpts ,
31+ ctx context. Context ,
3332 operatorAddress gethcommon.Address ,
3433 strategyAddresses []gethcommon.Address ,
3534 ) ([]uint64 , error )
3635 GetAllocatableMagnitude (
37- opts * bind. CallOpts ,
36+ ctx context. Context ,
3837 operator gethcommon.Address ,
3938 strategy gethcommon.Address ,
4039 ) (uint64 , error )
@@ -200,21 +199,21 @@ func generateAllocationsParams(
200199 config * updateConfig ,
201200 logger logging.Logger ,
202201) (* BulkModifyAllocations , error ) {
203- allocations := make ([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation , 0 )
202+ allocations := make ([]allocationmanager.IAllocationManagerTypesAllocateParams , 0 )
204203 var allocatableMagnitudes map [gethcommon.Address ]uint64
205204
206205 var err error
207206 if len (config .csvFilePath ) == 0 {
208207 magnitude , err := elReader .GetMaxMagnitudes (
209- & bind. CallOpts { Context : ctx } ,
208+ ctx ,
210209 config .operatorAddress ,
211210 []gethcommon.Address {config .strategyAddress },
212211 )
213212 if err != nil {
214213 return nil , eigenSdkUtils .WrapError ("failed to get latest total magnitude" , err )
215214 }
216215 allocatableMagnitude , err := elReader .GetAllocatableMagnitude (
217- & bind. CallOpts { Context : ctx } ,
216+ ctx ,
218217 config .operatorAddress ,
219218 config .strategyAddress ,
220219 )
@@ -226,16 +225,13 @@ func generateAllocationsParams(
226225 logger .Debugf ("Bips to allocate: %d" , config .bipsToAllocate )
227226 magnitudeToUpdate := calculateMagnitudeToUpdate (magnitude [0 ], config .bipsToAllocate )
228227 logger .Debugf ("Magnitude to update: %d" , magnitudeToUpdate )
229- malloc := allocationmanager.IAllocationManagerTypesMagnitudeAllocation {
230- Strategy : config .strategyAddress ,
231- ExpectedMaxMagnitude : magnitude [0 ],
232- OperatorSets : []allocationmanager.OperatorSet {
233- {
234- Avs : config .avsAddress ,
235- OperatorSetId : config .operatorSetId ,
236- },
228+ malloc := allocationmanager.IAllocationManagerTypesAllocateParams {
229+ Strategies : []gethcommon.Address {config .strategyAddress },
230+ OperatorSet : allocationmanager.OperatorSet {
231+ Avs : config .avsAddress ,
232+ Id : config .operatorSetId ,
237233 },
238- Magnitudes : []uint64 {magnitudeToUpdate },
234+ NewMagnitudes : []uint64 {magnitudeToUpdate },
239235 }
240236 allocations = append (allocations , malloc )
241237 } else {
@@ -255,7 +251,7 @@ func computeAllocations(
255251 filePath string ,
256252 operatorAddress gethcommon.Address ,
257253 elReader elChainReader ,
258- ) ([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation , map [gethcommon.Address ]uint64 , error ) {
254+ ) ([]allocationmanager.IAllocationManagerTypesAllocateParams , map [gethcommon.Address ]uint64 , error ) {
259255 allocations , err := parseAllocationsCSV (filePath )
260256 if err != nil {
261257 return nil , nil , eigenSdkUtils .WrapError ("failed to parse allocations csv" , err )
@@ -314,7 +310,7 @@ func parallelGetAllocatableMagnitudes(
314310 wg .Add (1 )
315311 go func (strategy gethcommon.Address ) {
316312 defer wg .Done ()
317- magnitude , err := elReader .GetAllocatableMagnitude (& bind. CallOpts {} , operatorAddress , strategy )
313+ magnitude , err := elReader .GetAllocatableMagnitude (context . Background () , operatorAddress , strategy )
318314 if err != nil {
319315 errChan <- err
320316 return
@@ -340,7 +336,7 @@ func getMagnitudes(
340336) (map [gethcommon.Address ]uint64 , error ) {
341337 strategyTotalMagnitudes := make (map [gethcommon.Address ]uint64 , len (strategies ))
342338 totalMagnitudes , err := reader .GetMaxMagnitudes (
343- & bind. CallOpts { Context : context .Background ()} ,
339+ context .Background (),
344340 operatorAddress ,
345341 strategies ,
346342 )
@@ -385,40 +381,62 @@ func parseAllocationsCSV(filePath string) ([]allocation, error) {
385381func convertAllocationsToMagnitudeAllocations (
386382 allocations []allocation ,
387383 strategyTotalMagnitudes map [gethcommon.Address ]uint64 ,
388- ) []allocationmanager.IAllocationManagerTypesMagnitudeAllocation {
389- magnitudeAllocations := make ([]allocationmanager.IAllocationManagerTypesMagnitudeAllocation , 0 )
390- operatorSetsPerStragyMap := make (map [gethcommon.Address ][]allocationmanager.OperatorSet )
391- magnitudeAllocationsPerStrategyMap := make (map [gethcommon.Address ][]uint64 )
384+ ) []allocationmanager.IAllocationManagerTypesAllocateParams {
385+ magnitudeAllocations := make ([]allocationmanager.IAllocationManagerTypesAllocateParams , 0 )
386+ //operatorSetsPerStragyMap := make(map[gethcommon.Address][]allocationmanager.OperatorSet)
387+ strategiesPerOperatorSetMap := make (map [allocationmanager.OperatorSet ][]gethcommon.Address )
388+ //magnitudeAllocationsPerStrategyMap := make(map[gethcommon.Address][]uint64)
389+ magnitudeAllocationsPerOperatorSetMap := make (map [allocationmanager.OperatorSet ][]uint64 )
392390 for _ , a := range allocations {
393391 totalMag := strategyTotalMagnitudes [a .StrategyAddress ]
394392 magnitudeToUpdate := calculateMagnitudeToUpdate (totalMag , a .Bips )
395393
396- operatorSets , ok := operatorSetsPerStragyMap [a .StrategyAddress ]
394+ opSet := allocationmanager.OperatorSet {Avs : a .AvsAddress , Id : a .OperatorSetId }
395+ strategies , ok := strategiesPerOperatorSetMap [opSet ]
397396 if ! ok {
398- operatorSets = make ([]allocationmanager. OperatorSet , 0 )
397+ strategies = make ([]gethcommon. Address , 0 )
399398 }
400- operatorSets = append (operatorSets , allocationmanager.OperatorSet {
401- Avs : a .AvsAddress ,
402- OperatorSetId : a .OperatorSetId ,
403- })
404- operatorSetsPerStragyMap [a .StrategyAddress ] = operatorSets
405399
406- magnitudes := magnitudeAllocationsPerStrategyMap [a .StrategyAddress ]
400+ strategies = append (strategies , a .StrategyAddress )
401+ strategiesPerOperatorSetMap [opSet ] = strategies
402+
403+ //operatorSets, ok := operatorSetsPerStragyMap[a.StrategyAddress]
404+ //if !ok {
405+ // operatorSets = make([]allocationmanager.OperatorSet, 0)
406+ //}
407+ //operatorSets = append(operatorSets, allocationmanager.OperatorSet{
408+ // Avs: a.AvsAddress,
409+ // Id: a.OperatorSetId,
410+ //})
411+ //operatorSetsPerStragyMap[a.StrategyAddress] = operatorSets
412+
413+ magnitudes := magnitudeAllocationsPerOperatorSetMap [opSet ]
407414 magnitudes = append (magnitudes , magnitudeToUpdate )
408- magnitudeAllocationsPerStrategyMap [ a . StrategyAddress ] = magnitudes
415+ magnitudeAllocationsPerOperatorSetMap [ opSet ] = magnitudes
409416 }
410417
411- for strategy , operatorSets := range operatorSetsPerStragyMap {
418+ for opSet , strategies := range strategiesPerOperatorSetMap {
412419 magnitudeAllocations = append (
413420 magnitudeAllocations ,
414- allocationmanager.IAllocationManagerTypesMagnitudeAllocation {
415- Strategy : strategy ,
416- ExpectedMaxMagnitude : strategyTotalMagnitudes [strategy ],
417- OperatorSets : operatorSets ,
418- Magnitudes : magnitudeAllocationsPerStrategyMap [strategy ],
421+ allocationmanager.IAllocationManagerTypesAllocateParams {
422+ OperatorSet : opSet ,
423+ Strategies : strategies ,
424+ NewMagnitudes : magnitudeAllocationsPerOperatorSetMap [opSet ],
419425 },
420426 )
421427 }
428+
429+ //for strategy, operatorSets := range operatorSetsPerStragyMap {
430+ // magnitudeAllocations = append(
431+ // magnitudeAllocations,
432+ // allocationmanager.IAllocationManagerTypesAllocateParams{
433+ // Strategy: strategy,
434+ // ExpectedMaxMagnitude: strategyTotalMagnitudes[strategy],
435+ // OperatorSets: operatorSets,
436+ // Magnitudes: magnitudeAllocationsPerStrategyMap[strategy],
437+ // },
438+ // )
439+ //}
422440 return magnitudeAllocations
423441}
424442
0 commit comments