Skip to content

Commit

Permalink
update with latest methods
Browse files Browse the repository at this point in the history
  • Loading branch information
shrimalmadhur committed Nov 19, 2024
1 parent ce9983d commit 3e79100
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 91 deletions.
30 changes: 12 additions & 18 deletions chainio/clients/elcontracts/reader.go
Original file line number Diff line number Diff line change
Expand Up @@ -485,23 +485,18 @@ func (r *ChainReader) GetStrategiesForOperatorSet(
}
}

type OperatorSetStakes struct {
OperatorSet allocationmanager.OperatorSet
Strategies []gethcommon.Address
Operators []gethcommon.Address
DelegatedStakes [][]*big.Int
SlashableStakes [][]*big.Int
}

// GetDelegatedAndSlashableSharesForOperatorSets returns the strategies the operatorSets take into account, their
// operators,
// and the minimum amount of shares that multiple operators delegated to them and slashable by the operatorSets.
// GetSlashableSharesForOperatorSets returns the strategies the operatorSets take into account, their
// operators, and the minimum amount of shares that are slashable by the operatorSets.
// Not supported for M2 AVSs
func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
func (r *ChainReader) GetSlashableSharesForOperatorSets(
opts *bind.CallOpts,
operatorSets []allocationmanager.OperatorSet,
) ([]OperatorSetStakes, error) {
operatorSetStakes := make([]OperatorSetStakes, len(operatorSets))
currentBlock, err := r.ethClient.BlockNumber(opts.Context)
if err != nil {
return nil, err
}
for i, operatorSet := range operatorSets {
operators, err := r.GetOperatorsForOperatorSet(opts, operatorSet)
if err != nil {
Expand All @@ -513,14 +508,15 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
return nil, err
}

delegatedShares, slashableShares, err := r.allocationManager.GetCurrentDelegatedAndSlashableOperatorShares(
slashableShares, err := r.allocationManager.GetMinimumSlashableStake(
opts,
allocationmanager.OperatorSet{
Id: operatorSet.Id,
Avs: operatorSet.Avs,
},
operators,
strategies,
uint32(currentBlock),
)
if err != nil {
return nil, err
Expand All @@ -530,7 +526,6 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
OperatorSet: operatorSet,
Strategies: strategies,
Operators: operators,
DelegatedStakes: delegatedShares,
SlashableStakes: slashableShares,
}
}
Expand All @@ -546,7 +541,7 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSets(
func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSetsBefore(
opts *bind.CallOpts,
operatorSets []allocationmanager.OperatorSet,
beforeTimestamp uint32,
futureBlock uint32,
) ([]OperatorSetStakes, error) {
operatorSetStakes := make([]OperatorSetStakes, len(operatorSets))
for i, operatorSet := range operatorSets {
Expand All @@ -560,15 +555,15 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSetsBefore(
return nil, err
}

delegatedShares, slashableShares, err := r.allocationManager.GetMinDelegatedAndSlashableOperatorSharesBefore(
slashableShares, err := r.allocationManager.GetMinimumSlashableStake(
opts,
allocationmanager.OperatorSet{
Id: operatorSet.Id,
Avs: operatorSet.Avs,
},
operators,
strategies,
beforeTimestamp,
futureBlock,
)
if err != nil {
return nil, err
Expand All @@ -578,7 +573,6 @@ func (r *ChainReader) GetDelegatedAndSlashableSharesForOperatorSetsBefore(
OperatorSet: operatorSet,
Strategies: strategies,
Operators: operators,
DelegatedStakes: delegatedShares,
SlashableStakes: slashableShares,
}
}
Expand Down
9 changes: 9 additions & 0 deletions chainio/clients/elcontracts/types.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ package elcontracts
import (
"math/big"

allocationmanager "github.com/Layr-Labs/eigensdk-go/contracts/bindings/AllocationManager"

"github.com/ethereum/go-ethereum/common"
)

Expand All @@ -18,3 +20,10 @@ type AllocationInfo struct {
OperatorSetId uint32
AvsAddress common.Address
}

type OperatorSetStakes struct {
OperatorSet allocationmanager.OperatorSet
Strategies []common.Address
Operators []common.Address
SlashableStakes [][]*big.Int
}
2 changes: 1 addition & 1 deletion contracts/bindings/AVSDirectory/binding.go

Large diffs are not rendered by default.

70 changes: 68 additions & 2 deletions contracts/bindings/AllocationManager/binding.go

Large diffs are not rendered by default.

126 changes: 68 additions & 58 deletions contracts/bindings/DelegationManager/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/bindings/EigenPod/binding.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions contracts/bindings/EigenPodManager/binding.go

Large diffs are not rendered by default.

10 changes: 5 additions & 5 deletions contracts/bindings/StrategyManager/binding.go

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion contracts/lib/eigenlayer-middleware

0 comments on commit 3e79100

Please sign in to comment.