@@ -381,30 +381,16 @@ type StakerShares struct {
381381// and the addresses of the AVSs the operator was registered to.
382382//
383383// If not blockHeight is provided, the most recently indexed block will be used.
384- // If showHistorical is true, returns all historical share records; otherwise returns aggregated current state.
385384// For historical results, startBlock and endBlock can be used to filter the block range.
386- func (pds * ProtocolDataService ) ListStakerShares (ctx context.Context , staker string , strategy string , blockHeight uint64 , showHistorical bool , startBlock uint64 , endBlock uint64 ) ([]* StakerShares , error ) {
387- // Validate that start and end blocks are required when historical is true
388- if showHistorical {
389- if startBlock == 0 {
390- return nil , errors .New ("startBlock is required when showHistorical is true" )
391- }
392- if endBlock == 0 {
393- return nil , errors .New ("endBlock is required when showHistorical is true" )
394- }
395- if startBlock > endBlock {
396- return nil , errors .New ("startBlock cannot be greater than endBlock" )
397- }
398- }
399-
400- bh , err := pds .BaseDataService .GetCurrentBlockHeightIfNotPresent (ctx , blockHeight )
385+ func (pds * ProtocolDataService ) ListStakerShares (ctx context.Context , staker string , strategy string , startBlock uint64 , endBlock uint64 ) ([]* StakerShares , error ) {
386+ bh , err := pds .BaseDataService .GetCurrentBlockHeightIfNotPresent (ctx , endBlock )
401387 if err != nil {
402388 return nil , err
403389 }
404390
405391 var query string
406392
407- if showHistorical {
393+ if startBlock > 0 && endBlock > 0 {
408394 query = `
409395 with distinct_staker_strategies as (
410396 select
@@ -478,16 +464,10 @@ func (pds *ProtocolDataService) ListStakerShares(ctx context.Context, staker str
478464 // Prepare query parameters
479465 queryParams := []interface {}{
480466 sql .Named ("staker" , staker ),
467+ sql .Named ("strategy" , strategy ),
481468 sql .Named ("blockHeight" , bh ),
482- }
483-
484- if strategy != "" {
485- queryParams = append (queryParams , sql .Named ("strategy" , strategy ))
486- }
487-
488- if showHistorical {
489- queryParams = append (queryParams , sql .Named ("startBlock" , startBlock ))
490- queryParams = append (queryParams , sql .Named ("endBlock" , endBlock ))
469+ sql .Named ("startBlock" , startBlock ),
470+ sql .Named ("endBlock" , endBlock ),
491471 }
492472
493473 res := pds .db .Raw (query , queryParams ... ).Scan (& shares )
0 commit comments