diff --git a/CHANGELOG.md b/CHANGELOG.md index 20ad24a5e69..f9a3b393f50 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -33,6 +33,7 @@ - [11028](https://github.com/vegaprotocol/vega/issues/11028) - Add API to estimate order book depth based on `vAMM`. - [11400](https://github.com/vegaprotocol/vega/issues/11400) - Add support for long block auction. - [11026](https://github.com/vegaprotocol/vega/issues/11026) - Add API flag to get paid liquidity fees for a `vAMM` using the parent key. +- [11027](https://github.com/vegaprotocol/vega/issues/11027) - Add API filters to get fees and rewards by market, across epochs. ### 🐛 Fixes diff --git a/datanode/api/trading_data_v2.go b/datanode/api/trading_data_v2.go index bf983fff6aa..7a8438d66f7 100644 --- a/datanode/api/trading_data_v2.go +++ b/datanode/api/trading_data_v2.go @@ -1903,15 +1903,19 @@ func (t *TradingDataServiceV2) ListRewards(ctx context.Context, req *v2.ListRewa } partyIDs := []string{req.PartyId} + var marketIDs []string + if req.MarketId != nil { + marketIDs = []string{*req.MarketId} + } if includeDerivedParties := ptr.UnBox(req.IncludeDerivedParties); includeDerivedParties { - subKeys, err := t.AMMPoolService.GetSubKeysForParties(ctx, partyIDs, nil) + subKeys, err := t.AMMPoolService.GetSubKeysForParties(ctx, partyIDs, marketIDs) if err != nil { return nil, formatE(err) } partyIDs = append(partyIDs, subKeys...) } - rewards, pageInfo, err := t.RewardService.GetByCursor(ctx, partyIDs, req.AssetId, req.FromEpoch, req.ToEpoch, pagination, req.TeamId, req.GameId) + rewards, pageInfo, err := t.RewardService.GetByCursor(ctx, partyIDs, req.AssetId, req.FromEpoch, req.ToEpoch, pagination, req.TeamId, req.GameId, req.MarketId) if err != nil { return nil, formatE(ErrGetRewards, err) } @@ -2517,7 +2521,7 @@ func (t *TradingDataServiceV2) ListPaidLiquidityFees(ctx context.Context, req *v } partyIDs = append(partyIDs, subKeys...) } - stats, pageInfo, err := t.paidLiquidityFeesStatsService.List(ctx, marketID, assetID, req.EpochSeq, partyIDs, pagination) + stats, pageInfo, err := t.paidLiquidityFeesStatsService.List(ctx, marketID, assetID, req.EpochSeq, partyIDs, pagination, req.EpochFrom, req.EpochTo) if err != nil { return nil, formatE(ErrListPaidLiquidityFees, err) } @@ -5208,7 +5212,7 @@ func (t *TradingDataServiceV2) GetFeesStats(ctx context.Context, req *v2.GetFees assetID = ptr.From(entities.AssetID(*req.AssetId)) } - stats, err := t.feesStatsService.GetFeesStats(ctx, marketID, assetID, req.EpochSeq, req.PartyId) + stats, err := t.feesStatsService.GetFeesStats(ctx, marketID, assetID, req.EpochSeq, req.PartyId, req.EpochFrom, req.EpochTo) if err != nil { return nil, formatE(ErrGetFeesStats, err) } diff --git a/datanode/api/trading_data_v2_test.go b/datanode/api/trading_data_v2_test.go index 22300f2366f..4319ecc7e7d 100644 --- a/datanode/api/trading_data_v2_test.go +++ b/datanode/api/trading_data_v2_test.go @@ -1150,7 +1150,7 @@ func TestListRewards(t *testing.T) { pagination := entities.DefaultCursorPagination(true) rewardStore.EXPECT().GetByCursor(ctx, - []string{req.PartyId}, req.AssetId, req.FromEpoch, req.ToEpoch, pagination, req.TeamId, req.GameId). + []string{req.PartyId}, req.AssetId, req.FromEpoch, req.ToEpoch, pagination, req.TeamId, req.GameId, req.MarketId). Times(1).Return(expect, entities.PageInfo{}, nil) resp, err := apiService.ListRewards(ctx, req) @@ -1183,8 +1183,8 @@ func TestListRewards(t *testing.T) { }, nil) rewardStore.EXPECT().GetByCursor(ctx, gomock.Any(), req.AssetId, req.FromEpoch, req.ToEpoch, - pagination, req.TeamId, req.GameId). - Do(func(_ context.Context, gotPartyIDs []string, _ *string, _, _ *uint64, _ entities.CursorPagination, _, _ *string) { + pagination, req.TeamId, req.GameId, req.MarketId). + Do(func(_ context.Context, gotPartyIDs []string, _ *string, _, _ *uint64, _ entities.CursorPagination, _, _, _ *string) { expectPartyIDs := []string{expect[0].PartyID.String(), expect[1].PartyID.String(), expect[2].PartyID.String()} slices.Sort(expectPartyIDs) diff --git a/datanode/gateway/graphql/generated.go b/datanode/gateway/graphql/generated.go index 533fb303feb..38849c4d4b9 100644 --- a/datanode/gateway/graphql/generated.go +++ b/datanode/gateway/graphql/generated.go @@ -1847,7 +1847,7 @@ type ComplexityRoot struct { PositionsConnection func(childComplexity int, market *string, pagination *v2.Pagination) int ProposalsConnection func(childComplexity int, proposalType *v2.ListGovernanceDataRequest_Type, inState *vega.Proposal_State, pagination *v2.Pagination) int RewardSummaries func(childComplexity int, assetID *string, includeDerivedParties *bool) int - RewardsConnection func(childComplexity int, assetID *string, pagination *v2.Pagination, fromEpoch *int, toEpoch *int, teamID *string, gameID *string, includeDerivedParties *bool) int + RewardsConnection func(childComplexity int, assetID *string, pagination *v2.Pagination, fromEpoch *int, toEpoch *int, teamID *string, gameID *string, includeDerivedParties *bool, marketID *string) int StakingSummary func(childComplexity int, pagination *v2.Pagination) int TradesConnection func(childComplexity int, marketID *string, dataRange *v2.DateRange, pagination *v2.Pagination) int TransfersConnection func(childComplexity int, direction *TransferDirection, pagination *v2.Pagination, isReward *bool, fromEpoch *int, toEpoch *int, status *v1.Transfer_Status, scope *v2.ListTransfersRequest_Scope, gameID *string, fromAccountType *vega.AccountType, toAccountType *vega.AccountType) int @@ -2226,7 +2226,7 @@ type ComplexityRoot struct { EstimatePosition func(childComplexity int, marketID string, openVolume string, averageEntryPrice string, orders []*v2.OrderInfo, marginAccountBalance string, generalAccountBalance string, orderMarginAccountBalance string, marginMode vega.MarginMode, marginFactor *string, includeRequiredPositionMarginInAvailableCollateral *bool, scaleLiquidationPriceToMarketDecimals *bool) int EstimateTransferFee func(childComplexity int, fromAccount string, fromAccountType vega.AccountType, toAccount string, amount string, assetID string) int EthereumKeyRotations func(childComplexity int, nodeID *string) int - FeesStats func(childComplexity int, marketID *string, assetID *string, epoch *int, partyID *string) int + FeesStats func(childComplexity int, marketID *string, assetID *string, epoch *int, partyID *string, epochFrom *int, epochTo *int) int FeesStatsForParty func(childComplexity int, partyID string, assetID *string, fromEpoch *int, toEpoch *int) int FundingPayments func(childComplexity int, partyID string, marketID *string, pagination *v2.Pagination) int FundingPeriodDataPoints func(childComplexity int, marketID string, dateRange *v2.DateRange, source *v1.FundingPeriodDataPoint_Source, pagination *v2.Pagination) int @@ -2256,7 +2256,7 @@ type ComplexityRoot struct { OrderByID func(childComplexity int, id string, version *int) int OrderByReference func(childComplexity int, reference string) int OrderVersionsConnection func(childComplexity int, orderID *string, pagination *v2.Pagination) int - PaidLiquidityFees func(childComplexity int, marketID *string, assetID *string, epoch *int, partyIDs []string, includeDerivedParties *bool) int + PaidLiquidityFees func(childComplexity int, marketID *string, assetID *string, epoch *int, partyIDs []string, includeDerivedParties *bool, epochFrom *int, epochTo *int) int PartiesConnection func(childComplexity int, id *string, pagination *v2.Pagination) int PartiesProfilesConnection func(childComplexity int, ids []string, pagination *v2.Pagination) int Party func(childComplexity int, id string) int @@ -3561,7 +3561,7 @@ type PartyResolver interface { LiquidityProvisionsConnection(ctx context.Context, obj *vega.Party, marketID *string, reference *string, live *bool, pagination *v2.Pagination) (*v2.LiquidityProvisionsConnection, error) DelegationsConnection(ctx context.Context, obj *vega.Party, nodeID *string, pagination *v2.Pagination) (*v2.DelegationsConnection, error) StakingSummary(ctx context.Context, obj *vega.Party, pagination *v2.Pagination) (*StakingSummary, error) - RewardsConnection(ctx context.Context, obj *vega.Party, assetID *string, pagination *v2.Pagination, fromEpoch *int, toEpoch *int, teamID *string, gameID *string, includeDerivedParties *bool) (*v2.RewardsConnection, error) + RewardsConnection(ctx context.Context, obj *vega.Party, assetID *string, pagination *v2.Pagination, fromEpoch *int, toEpoch *int, teamID *string, gameID *string, includeDerivedParties *bool, marketID *string) (*v2.RewardsConnection, error) RewardSummaries(ctx context.Context, obj *vega.Party, assetID *string, includeDerivedParties *bool) ([]*vega.RewardSummary, error) TransfersConnection(ctx context.Context, obj *vega.Party, direction *TransferDirection, pagination *v2.Pagination, isReward *bool, fromEpoch *int, toEpoch *int, status *v1.Transfer_Status, scope *v2.ListTransfersRequest_Scope, gameID *string, fromAccountType *vega.AccountType, toAccountType *vega.AccountType) (*v2.TransferConnection, error) ActivityStreak(ctx context.Context, obj *vega.Party, epoch *int) (*v1.PartyActivityStreak, error) @@ -3700,7 +3700,7 @@ type QueryResolver interface { EstimateAMMBounds(ctx context.Context, basePrice string, upperPrice *string, lowerPrice *string, leverageAtUpperPrice *string, leverageAtLowerPrice *string, commitmentAmount string, marketID string) (*v2.EstimateAMMBoundsResponse, error) EthereumKeyRotations(ctx context.Context, nodeID *string) (*v2.EthereumKeyRotationsConnection, error) EstimateTransferFee(ctx context.Context, fromAccount string, fromAccountType vega.AccountType, toAccount string, amount string, assetID string) (*v2.EstimateTransferFeeResponse, error) - FeesStats(ctx context.Context, marketID *string, assetID *string, epoch *int, partyID *string) (*v1.FeesStats, error) + FeesStats(ctx context.Context, marketID *string, assetID *string, epoch *int, partyID *string, epochFrom *int, epochTo *int) (*v1.FeesStats, error) FeesStatsForParty(ctx context.Context, partyID string, assetID *string, fromEpoch *int, toEpoch *int) ([]*v2.FeesStatsForParty, error) FundingPayments(ctx context.Context, partyID string, marketID *string, pagination *v2.Pagination) (*v2.FundingPaymentConnection, error) FundingPeriods(ctx context.Context, marketID string, dateRange *v2.DateRange, pagination *v2.Pagination) (*v2.FundingPeriodConnection, error) @@ -3728,7 +3728,7 @@ type QueryResolver interface { OrderByID(ctx context.Context, id string, version *int) (*vega.Order, error) OrderByReference(ctx context.Context, reference string) (*vega.Order, error) OrderVersionsConnection(ctx context.Context, orderID *string, pagination *v2.Pagination) (*v2.OrderConnection, error) - PaidLiquidityFees(ctx context.Context, marketID *string, assetID *string, epoch *int, partyIDs []string, includeDerivedParties *bool) (*v2.PaidLiquidityFeesConnection, error) + PaidLiquidityFees(ctx context.Context, marketID *string, assetID *string, epoch *int, partyIDs []string, includeDerivedParties *bool, epochFrom *int, epochTo *int) (*v2.PaidLiquidityFeesConnection, error) PartiesConnection(ctx context.Context, id *string, pagination *v2.Pagination) (*v2.PartyConnection, error) PartiesProfilesConnection(ctx context.Context, ids []string, pagination *v2.Pagination) (*v2.PartiesProfilesConnection, error) Party(ctx context.Context, id string) (*vega.Party, error) @@ -11166,7 +11166,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Party.RewardsConnection(childComplexity, args["assetId"].(*string), args["pagination"].(*v2.Pagination), args["fromEpoch"].(*int), args["toEpoch"].(*int), args["teamId"].(*string), args["gameId"].(*string), args["includeDerivedParties"].(*bool)), true + return e.complexity.Party.RewardsConnection(childComplexity, args["assetId"].(*string), args["pagination"].(*v2.Pagination), args["fromEpoch"].(*int), args["toEpoch"].(*int), args["teamId"].(*string), args["gameId"].(*string), args["includeDerivedParties"].(*bool), args["marketId"].(*string)), true case "Party.stakingSummary": if e.complexity.Party.StakingSummary == nil { @@ -12914,7 +12914,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.FeesStats(childComplexity, args["marketId"].(*string), args["assetId"].(*string), args["epoch"].(*int), args["partyId"].(*string)), true + return e.complexity.Query.FeesStats(childComplexity, args["marketId"].(*string), args["assetId"].(*string), args["epoch"].(*int), args["partyId"].(*string), args["epochFrom"].(*int), args["epochTo"].(*int)), true case "Query.feesStatsForParty": if e.complexity.Query.FeesStatsForParty == nil { @@ -13254,7 +13254,7 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return 0, false } - return e.complexity.Query.PaidLiquidityFees(childComplexity, args["marketId"].(*string), args["assetId"].(*string), args["epoch"].(*int), args["partyIDs"].([]string), args["includeDerivedParties"].(*bool)), true + return e.complexity.Query.PaidLiquidityFees(childComplexity, args["marketId"].(*string), args["assetId"].(*string), args["epoch"].(*int), args["partyIDs"].([]string), args["includeDerivedParties"].(*bool), args["epochFrom"].(*int), args["epochTo"].(*int)), true case "Query.partiesConnection": if e.complexity.Query.PartiesConnection == nil { @@ -17716,6 +17716,15 @@ func (ec *executionContext) field_Party_rewardsConnection_args(ctx context.Conte } } args["includeDerivedParties"] = arg6 + var arg7 *string + if tmp, ok := rawArgs["marketId"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("marketId")) + arg7, err = ec.unmarshalOID2ᚖstring(ctx, tmp) + if err != nil { + return nil, err + } + } + args["marketId"] = arg7 return args, nil } @@ -18820,6 +18829,24 @@ func (ec *executionContext) field_Query_feesStats_args(ctx context.Context, rawA } } args["partyId"] = arg3 + var arg4 *int + if tmp, ok := rawArgs["epochFrom"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("epochFrom")) + arg4, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["epochFrom"] = arg4 + var arg5 *int + if tmp, ok := rawArgs["epochTo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("epochTo")) + arg5, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["epochTo"] = arg5 return args, nil } @@ -19492,6 +19519,24 @@ func (ec *executionContext) field_Query_paidLiquidityFees_args(ctx context.Conte } } args["includeDerivedParties"] = arg4 + var arg5 *int + if tmp, ok := rawArgs["epochFrom"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("epochFrom")) + arg5, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["epochFrom"] = arg5 + var arg6 *int + if tmp, ok := rawArgs["epochTo"]; ok { + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("epochTo")) + arg6, err = ec.unmarshalOInt2ᚖint(ctx, tmp) + if err != nil { + return nil, err + } + } + args["epochTo"] = arg6 return args, nil } @@ -68932,7 +68977,7 @@ func (ec *executionContext) _Party_rewardsConnection(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Party().RewardsConnection(rctx, obj, fc.Args["assetId"].(*string), fc.Args["pagination"].(*v2.Pagination), fc.Args["fromEpoch"].(*int), fc.Args["toEpoch"].(*int), fc.Args["teamId"].(*string), fc.Args["gameId"].(*string), fc.Args["includeDerivedParties"].(*bool)) + return ec.resolvers.Party().RewardsConnection(rctx, obj, fc.Args["assetId"].(*string), fc.Args["pagination"].(*v2.Pagination), fc.Args["fromEpoch"].(*int), fc.Args["toEpoch"].(*int), fc.Args["teamId"].(*string), fc.Args["gameId"].(*string), fc.Args["includeDerivedParties"].(*bool), fc.Args["marketId"].(*string)) }) if err != nil { ec.Error(ctx, err) @@ -80134,7 +80179,7 @@ func (ec *executionContext) _Query_feesStats(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().FeesStats(rctx, fc.Args["marketId"].(*string), fc.Args["assetId"].(*string), fc.Args["epoch"].(*int), fc.Args["partyId"].(*string)) + return ec.resolvers.Query().FeesStats(rctx, fc.Args["marketId"].(*string), fc.Args["assetId"].(*string), fc.Args["epoch"].(*int), fc.Args["partyId"].(*string), fc.Args["epochFrom"].(*int), fc.Args["epochTo"].(*int)) }) if err != nil { ec.Error(ctx, err) @@ -81956,7 +82001,7 @@ func (ec *executionContext) _Query_paidLiquidityFees(ctx context.Context, field }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return ec.resolvers.Query().PaidLiquidityFees(rctx, fc.Args["marketId"].(*string), fc.Args["assetId"].(*string), fc.Args["epoch"].(*int), fc.Args["partyIDs"].([]string), fc.Args["includeDerivedParties"].(*bool)) + return ec.resolvers.Query().PaidLiquidityFees(rctx, fc.Args["marketId"].(*string), fc.Args["assetId"].(*string), fc.Args["epoch"].(*int), fc.Args["partyIDs"].([]string), fc.Args["includeDerivedParties"].(*bool), fc.Args["epochFrom"].(*int), fc.Args["epochTo"].(*int)) }) if err != nil { ec.Error(ctx, err) diff --git a/datanode/gateway/graphql/resolvers.go b/datanode/gateway/graphql/resolvers.go index 40d97d84e82..2f1374006a6 100644 --- a/datanode/gateway/graphql/resolvers.go +++ b/datanode/gateway/graphql/resolvers.go @@ -2084,19 +2084,27 @@ func (r *myQueryResolver) TeamRefereeHistory(ctx context.Context, referee string } func (r *myQueryResolver) FeesStats(ctx context.Context, marketID *string, assetID *string, epoch *int, - partyID *string, + partyID *string, epochFrom, epochTo *int, ) (*v1.FeesStats, error) { - var epochSeq *uint64 + var epochSeq, from, to *uint64 if epoch != nil { epochSeq = ptr.From(uint64(*epoch)) } + if epochFrom != nil { + from = ptr.From(uint64(*epochFrom)) + } + if epochTo != nil { + to = ptr.From(uint64(*epochTo)) + } req := &v2.GetFeesStatsRequest{ - MarketId: marketID, - AssetId: assetID, - EpochSeq: epochSeq, - PartyId: partyID, + MarketId: marketID, + AssetId: assetID, + EpochSeq: epochSeq, + PartyId: partyID, + EpochFrom: from, + EpochTo: to, } resp, err := r.tradingDataClientV2.GetFeesStats(ctx, req) @@ -2140,12 +2148,19 @@ func (r *myQueryResolver) PaidLiquidityFees( epoch *int, partyIDs []string, includeDerivedParties *bool, + from, to *int, ) (*v2.PaidLiquidityFeesConnection, error) { - var epochSeq *uint64 + var epochSeq, epochFrom, epochTo *uint64 if epoch != nil { epochSeq = ptr.From(uint64(*epoch)) } + if from != nil { + epochFrom = ptr.From(uint64(*from)) + } + if to != nil { + epochTo = ptr.From(uint64(*to)) + } req := &v2.ListPaidLiquidityFeesRequest{ MarketId: marketID, @@ -2153,6 +2168,8 @@ func (r *myQueryResolver) PaidLiquidityFees( EpochSeq: epochSeq, PartyIds: partyIDs, IncludeDerivedParties: includeDerivedParties, + EpochFrom: epochFrom, + EpochTo: epochTo, } resp, err := r.tradingDataClientV2.ListPaidLiquidityFees(ctx, req) @@ -2283,7 +2300,7 @@ func (r *myPartyResolver) TransfersConnection( } func (r *myPartyResolver) RewardsConnection(ctx context.Context, party *vegapb.Party, assetID *string, pagination *v2.Pagination, - fromEpoch *int, toEpoch *int, teamID, gameID *string, includeDerivedParties *bool, + fromEpoch *int, toEpoch *int, teamID, gameID *string, includeDerivedParties *bool, marketID *string, ) (*v2.RewardsConnection, error) { var from, to *uint64 @@ -2311,6 +2328,7 @@ func (r *myPartyResolver) RewardsConnection(ctx context.Context, party *vegapb.P TeamId: teamID, GameId: gameID, IncludeDerivedParties: includeDerivedParties, + MarketId: marketID, } resp, err := r.tradingDataClientV2.ListRewards(ctx, &req) if err != nil { diff --git a/datanode/gateway/graphql/schema.graphql b/datanode/gateway/graphql/schema.graphql index ac84f2cdeba..eab9b1c5805 100644 --- a/datanode/gateway/graphql/schema.graphql +++ b/datanode/gateway/graphql/schema.graphql @@ -826,6 +826,10 @@ type Query { epoch: Int "Optional party ID to filter for" partyId: ID + "Optional epoch to filter from (included). If omitted, the last epoch will be used." + epochFrom: Int + "Optional epoch to filter to (included). If omitted, the last epoch will be used." + epochTo: Int ): FeesStats "Get fees statistics for a given party" @@ -1063,12 +1067,16 @@ type Query { marketId: ID "Optional asset ID to filter for." assetId: ID - "Optional epoch to filter for. If omitted, the most recent epoch's data is returned." + "Optional epoch to filter for. If no epoch filters are provided, the most recent epoch's data is returned." epoch: Int "Optional party IDs to filter for" partyIDs: [String!] "Whether to return all derived parties from AMMs for the given party. If used, party ID is required" includeDerivedParties: Boolean + "Start epoch to return the results from (inclusive), if no epoch filters are provided, the most recent epoch's data is returned." + epochFrom: Int + "End epoch to return the results to (inclusive), if no epoch filters are provided, the most recent epoch's data is returned." + epochTo: Int ): PaidLiquidityFeesConnection "One or more entities that are trading on the Vega network" @@ -3048,6 +3056,8 @@ type Party { gameId: ID "Whether to return rewards for all derived parties from AMMs for the given party. If used, party ID is required" includeDerivedParties: Boolean + "Optionally filter for rewards by market ID" + marketId: ID ): RewardsConnection "Return net reward information" diff --git a/datanode/service/mocks/mocks.go b/datanode/service/mocks/mocks.go index e07ec108cee..93cb71bbcb2 100644 --- a/datanode/service/mocks/mocks.go +++ b/datanode/service/mocks/mocks.go @@ -707,9 +707,9 @@ func (mr *MockRewardStoreMockRecorder) GetAll(arg0 interface{}) *gomock.Call { } // GetByCursor mocks base method. -func (m *MockRewardStore) GetByCursor(arg0 context.Context, arg1 []string, arg2 *string, arg3, arg4 *uint64, arg5 entities.CursorPagination, arg6, arg7 *string) ([]entities.Reward, entities.PageInfo, error) { +func (m *MockRewardStore) GetByCursor(arg0 context.Context, arg1 []string, arg2 *string, arg3, arg4 *uint64, arg5 entities.CursorPagination, arg6, arg7, arg8 *string) ([]entities.Reward, entities.PageInfo, error) { m.ctrl.T.Helper() - ret := m.ctrl.Call(m, "GetByCursor", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + ret := m.ctrl.Call(m, "GetByCursor", arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) ret0, _ := ret[0].([]entities.Reward) ret1, _ := ret[1].(entities.PageInfo) ret2, _ := ret[2].(error) @@ -717,9 +717,9 @@ func (m *MockRewardStore) GetByCursor(arg0 context.Context, arg1 []string, arg2 } // GetByCursor indicates an expected call of GetByCursor. -func (mr *MockRewardStoreMockRecorder) GetByCursor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7 interface{}) *gomock.Call { +func (mr *MockRewardStoreMockRecorder) GetByCursor(arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8 interface{}) *gomock.Call { mr.mock.ctrl.T.Helper() - return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByCursor", reflect.TypeOf((*MockRewardStore)(nil).GetByCursor), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7) + return mr.mock.ctrl.RecordCallWithMethodType(mr.mock, "GetByCursor", reflect.TypeOf((*MockRewardStore)(nil).GetByCursor), arg0, arg1, arg2, arg3, arg4, arg5, arg6, arg7, arg8) } // GetByTxHash mocks base method. diff --git a/datanode/service/rewards.go b/datanode/service/rewards.go index 3674d6cc4cb..f85338f24fe 100644 --- a/datanode/service/rewards.go +++ b/datanode/service/rewards.go @@ -26,7 +26,7 @@ type RewardStore interface { Add(ctx context.Context, r entities.Reward) error GetAll(ctx context.Context) ([]entities.Reward, error) GetByTxHash(ctx context.Context, txHash entities.TxHash) ([]entities.Reward, error) - GetByCursor(ctx context.Context, partyID []string, assetID *string, fromEpoch, toEpoch *uint64, p entities.CursorPagination, teamID, gameID *string) ([]entities.Reward, entities.PageInfo, error) + GetByCursor(ctx context.Context, partyID []string, assetID *string, fromEpoch, toEpoch *uint64, p entities.CursorPagination, teamID, gameID, marketID *string) ([]entities.Reward, entities.PageInfo, error) GetSummaries(ctx context.Context, partyID []string, assetID *string) ([]entities.RewardSummary, error) GetEpochSummaries(ctx context.Context, filter entities.RewardSummaryFilter, p entities.CursorPagination) ([]entities.EpochRewardSummary, entities.PageInfo, error) } @@ -57,8 +57,8 @@ func (r *Reward) GetByTxHash(ctx context.Context, txHash entities.TxHash) ([]ent return r.store.GetByTxHash(ctx, txHash) } -func (r *Reward) GetByCursor(ctx context.Context, partyIDs []string, assetID *string, fromEpoch, toEpoch *uint64, p entities.CursorPagination, teamID, gameID *string) ([]entities.Reward, entities.PageInfo, error) { - return r.store.GetByCursor(ctx, partyIDs, assetID, fromEpoch, toEpoch, p, teamID, gameID) +func (r *Reward) GetByCursor(ctx context.Context, partyIDs []string, assetID *string, fromEpoch, toEpoch *uint64, p entities.CursorPagination, teamID, gameID, marketID *string) ([]entities.Reward, entities.PageInfo, error) { + return r.store.GetByCursor(ctx, partyIDs, assetID, fromEpoch, toEpoch, p, teamID, gameID, marketID) } func (r *Reward) GetSummaries(ctx context.Context, partyIDs []string, assetID *string) ([]entities.RewardSummary, error) { diff --git a/datanode/sqlstore/fees_stats.go b/datanode/sqlstore/fees_stats.go index ac2b1805081..5cf3cf08475 100644 --- a/datanode/sqlstore/fees_stats.go +++ b/datanode/sqlstore/fees_stats.go @@ -148,7 +148,7 @@ func (rfs *FeesStats) StatsForParty(ctx context.Context, partyID entities.PartyI return stats, nil } -func (rfs *FeesStats) GetFeesStats(ctx context.Context, marketID *entities.MarketID, assetID *entities.AssetID, epochSeq *uint64, partyID *string) (*entities.FeesStats, error) { +func (rfs *FeesStats) GetFeesStats(ctx context.Context, marketID *entities.MarketID, assetID *entities.AssetID, epochSeq *uint64, partyID *string, epochFrom, epochTo *uint64) (*entities.FeesStats, error) { defer metrics.StartSQLQuery("FeesStats", "GetFeesStats")() var ( stats []entities.FeesStats @@ -175,7 +175,19 @@ func (rfs *FeesStats) GetFeesStats(ctx context.Context, marketID *entities.Marke where = append(where, fmt.Sprintf("market_id = %s", nextBindVar(&args, *marketID))) } - if epochSeq == nil { // we want the most recent stat so order and limit the query + if epochFrom != nil && epochTo != nil && *epochFrom > *epochTo { + epochFrom, epochTo = epochTo, epochFrom + } + if epochFrom != nil { + where = append(where, fmt.Sprintf("epoch_seq >= %s", nextBindVar(&args, *epochFrom))) + epochSeq = nil + } + if epochTo != nil { + where = append(where, fmt.Sprintf("epoch_seq <= %s", nextBindVar(&args, *epochTo))) + epochSeq = nil + } + + if epochSeq == nil && epochFrom == nil && epochTo == nil { // we want the most recent stat so order and limit the query where = append(where, "epoch_seq = (SELECT MAX(epoch_seq) FROM fees_stats)") } diff --git a/datanode/sqlstore/fees_stats_test.go b/datanode/sqlstore/fees_stats_test.go index 297ffb38de0..9f9f6a0b718 100644 --- a/datanode/sqlstore/fees_stats_test.go +++ b/datanode/sqlstore/fees_stats_test.go @@ -137,13 +137,13 @@ func testGetFeesStatsForMarketAndEpoch(t *testing.T) { // get the stats for the first market and epoch want := stats[0] - got, err := stores.fs.GetFeesStats(ctx, &want.MarketID, nil, &want.EpochSeq, nil) + got, err := stores.fs.GetFeesStats(ctx, &want.MarketID, nil, &want.EpochSeq, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) // get the stats for the second market and epoch want = stats[3] - got, err = stores.fs.GetFeesStats(ctx, &want.MarketID, nil, &want.EpochSeq, nil) + got, err = stores.fs.GetFeesStats(ctx, &want.MarketID, nil, &want.EpochSeq, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } @@ -155,13 +155,13 @@ func testGetFeesStatsForAssetAndEpoch(t *testing.T) { // get the stats for the first market and epoch want := stats[0] - got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, &want.EpochSeq, nil) + got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, &want.EpochSeq, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) // get the stats for the second market and epoch want = stats[6] - got, err = stores.fs.GetFeesStats(ctx, nil, &want.AssetID, &want.EpochSeq, nil) + got, err = stores.fs.GetFeesStats(ctx, nil, &want.AssetID, &want.EpochSeq, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } @@ -173,13 +173,13 @@ func testGetFeesStatsForMarketLatest(t *testing.T) { // get the stats for the first market and epoch want := stats[2] - got, err := stores.fs.GetFeesStats(ctx, &want.MarketID, nil, nil, nil) + got, err := stores.fs.GetFeesStats(ctx, &want.MarketID, nil, nil, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) // get the stats for the second market and epoch want = stats[8] - got, err = stores.fs.GetFeesStats(ctx, &want.MarketID, nil, nil, nil) + got, err = stores.fs.GetFeesStats(ctx, &want.MarketID, nil, nil, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } @@ -191,13 +191,13 @@ func testGetFeesStatsForAssetLatest(t *testing.T) { // get the stats for the first market and epoch want := stats[2] - got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, nil) + got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) // get the stats for the second market and epoch want = stats[8] - got, err = stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, nil) + got, err = stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, nil, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } @@ -206,7 +206,7 @@ func testGetFeesStatsNoAssetOrMarket(t *testing.T) { stores := setupFeesStatsStores(t) ctx := tempTransaction(t) - _, err := stores.fs.GetFeesStats(ctx, ptr.From(entities.MarketID("deadbeef01")), ptr.From(entities.AssetID("deadbeef02")), nil, nil) + _, err := stores.fs.GetFeesStats(ctx, ptr.From(entities.MarketID("deadbeef01")), ptr.From(entities.AssetID("deadbeef02")), nil, nil, nil, nil) require.Error(t, err) } @@ -249,7 +249,7 @@ func testGetFeesStatsForPartyAndEpoch(t *testing.T) { VegaTime: expected.VegaTime, } - got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, ptr.From(want.EpochSeq), &want.ReferrerRewardsGenerated[0].Referrer) + got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, ptr.From(want.EpochSeq), &want.ReferrerRewardsGenerated[0].Referrer, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } @@ -292,7 +292,7 @@ func testGetFeesStatsForPartyLatest(t *testing.T) { MakerFeesGenerated: []*eventspb.MakerFeesGenerated{}, VegaTime: expected.VegaTime, } - got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, &want.ReferrerRewardsGenerated[0].Referrer) + got, err := stores.fs.GetFeesStats(ctx, nil, &want.AssetID, nil, &want.ReferrerRewardsGenerated[0].Referrer, nil, nil) require.NoError(t, err) assert.Equal(t, want, *got) } diff --git a/datanode/sqlstore/paid_liquidity_fee_stats.go b/datanode/sqlstore/paid_liquidity_fee_stats.go index 846ba235c96..bba1ec3b771 100644 --- a/datanode/sqlstore/paid_liquidity_fee_stats.go +++ b/datanode/sqlstore/paid_liquidity_fee_stats.go @@ -69,6 +69,7 @@ func (lfs *PaidLiquidityFeesStats) List( epochSeq *uint64, partyIDs []string, pagination entities.CursorPagination, + epochFrom, epochTo *uint64, ) ([]entities.PaidLiquidityFeesStats, entities.PageInfo, error) { defer metrics.StartSQLQuery("PaidLiquidityFeesStats", "List")() var ( @@ -81,11 +82,22 @@ func (lfs *PaidLiquidityFeesStats) List( whereClauses := []string{} - if (marketID == nil || assetID == nil) && epochSeq == nil { + if (marketID == nil || assetID == nil) && epochSeq == nil && epochFrom == nil && epochTo == nil { whereClauses = append(whereClauses, "epoch_seq = (SELECT MAX(epoch_seq) FROM paid_liquidity_fees)") } - if epochSeq != nil { + // to from range set, but wrong way around + if epochFrom != nil && epochTo != nil && *epochFrom > *epochTo { + epochTo, epochFrom = epochFrom, epochTo + } + if epochFrom != nil { + whereClauses = append(whereClauses, fmt.Sprintf("epoch_seq >= %s", nextBindVar(&args, *epochFrom))) + } + if epochTo != nil { + whereClauses = append(whereClauses, fmt.Sprintf("epoch_seq <= %s", nextBindVar(&args, *epochTo))) + } + // @TODO remove precise epoch sequence? + if epochFrom == nil && epochTo == nil && epochSeq != nil { whereClauses = append(whereClauses, fmt.Sprintf("epoch_seq = %s", nextBindVar(&args, *epochSeq))) } diff --git a/datanode/sqlstore/paid_liquidity_fee_stats_test.go b/datanode/sqlstore/paid_liquidity_fee_stats_test.go index 0d10f1d3b2b..f384158feb1 100644 --- a/datanode/sqlstore/paid_liquidity_fee_stats_test.go +++ b/datanode/sqlstore/paid_liquidity_fee_stats_test.go @@ -250,7 +250,7 @@ func testListPaidLiquidityFeesStatsForMarketAndEpoch(t *testing.T) { // get the stats for the first market and epoch want := stats[0:1] - got, _, err := stores.ls.List(ctx, &want[0].MarketID, nil, &want[0].EpochSeq, nil, pagination) + got, _, err := stores.ls.List(ctx, &want[0].MarketID, nil, &want[0].EpochSeq, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -258,7 +258,7 @@ func testListPaidLiquidityFeesStatsForMarketAndEpoch(t *testing.T) { // get the stats for the second market and epoch want = stats[3:4] - got, _, err = stores.ls.List(ctx, &want[0].MarketID, nil, &want[0].EpochSeq, nil, pagination) + got, _, err = stores.ls.List(ctx, &want[0].MarketID, nil, &want[0].EpochSeq, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -274,7 +274,7 @@ func testListPaidLiquidityFeesStatsForAssetAndEpoch(t *testing.T) { // get the stats for the first market and epoch want := stats[1:2] - got, _, err := stores.ls.List(ctx, nil, &want[0].AssetID, &want[0].EpochSeq, nil, pagination) + got, _, err := stores.ls.List(ctx, nil, &want[0].AssetID, &want[0].EpochSeq, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -282,7 +282,7 @@ func testListPaidLiquidityFeesStatsForAssetAndEpoch(t *testing.T) { // get the stats for the second market and epoch want = stats[4:5] - got, _, err = stores.ls.List(ctx, nil, &want[0].AssetID, &want[0].EpochSeq, nil, pagination) + got, _, err = stores.ls.List(ctx, nil, &want[0].AssetID, &want[0].EpochSeq, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -298,7 +298,7 @@ func testListPaidLiquidityFeesStatsForMarketLatest(t *testing.T) { // get the stats for the first market and epoch want := stats[2:3] - got, _, err := stores.ls.List(ctx, &want[0].MarketID, nil, nil, nil, pagination) + got, _, err := stores.ls.List(ctx, &want[0].MarketID, nil, nil, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -306,7 +306,7 @@ func testListPaidLiquidityFeesStatsForMarketLatest(t *testing.T) { // get the stats for the second market and epoch want = stats[5:6] - got, _, err = stores.ls.List(ctx, &want[0].MarketID, nil, nil, nil, pagination) + got, _, err = stores.ls.List(ctx, &want[0].MarketID, nil, nil, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -322,7 +322,7 @@ func testListPaidLiquidityFeesStatsForAssetLatest(t *testing.T) { // get the stats for the first market and epoch want := stats[2:3] - got, _, err := stores.ls.List(ctx, nil, &want[0].AssetID, nil, nil, pagination) + got, _, err := stores.ls.List(ctx, nil, &want[0].AssetID, nil, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -330,7 +330,7 @@ func testListPaidLiquidityFeesStatsForAssetLatest(t *testing.T) { // get the stats for the second market and epoch want = stats[5:6] - got, _, err = stores.ls.List(ctx, nil, &want[0].AssetID, nil, nil, pagination) + got, _, err = stores.ls.List(ctx, nil, &want[0].AssetID, nil, nil, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -349,7 +349,7 @@ func testListPaidLiquidityFeesStatsForPartyAndEpoch(t *testing.T) { want[0].FeesPerParty = want[0].FeesPerParty[:1] want[1].FeesPerParty = want[1].FeesPerParty[:1] - got, _, err := stores.ls.List(ctx, nil, nil, &want[0].EpochSeq, []string{want[0].FeesPerParty[0].Party}, pagination) + got, _, err := stores.ls.List(ctx, nil, nil, &want[0].EpochSeq, []string{want[0].FeesPerParty[0].Party}, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) @@ -369,7 +369,7 @@ func testListPaidLiquidityFeesStatsForPartyLatest(t *testing.T) { want[0].FeesPerParty = want[0].FeesPerParty[:1] want[1].FeesPerParty = want[1].FeesPerParty[:1] - got, _, err := stores.ls.List(ctx, nil, nil, nil, []string{want[0].FeesPerParty[0].Party}, pagination) + got, _, err := stores.ls.List(ctx, nil, nil, nil, []string{want[0].FeesPerParty[0].Party}, pagination, nil, nil) require.NoError(t, err) assert.Len(t, got, len(want)) diff --git a/datanode/sqlstore/rewards.go b/datanode/sqlstore/rewards.go index 62668a9ec65..c63d5ae7fc0 100644 --- a/datanode/sqlstore/rewards.go +++ b/datanode/sqlstore/rewards.go @@ -180,18 +180,18 @@ func (rs *Rewards) GetByCursor(ctx context.Context, fromEpoch *uint64, toEpoch *uint64, pagination entities.CursorPagination, - teamIDHex, gameIDHex *string, + teamIDHex, gameIDHex, marketID *string, ) ([]entities.Reward, entities.PageInfo, error) { var pageInfo entities.PageInfo query := ` WITH cte_rewards AS ( SELECT r.*, grt.team_id FROM rewards r - LEFT JOIN game_reward_totals grt ON r.game_id = grt.game_id AND r.party_id = grt.party_id and r.epoch_id = grt.epoch_id + LEFT JOIN game_reward_totals grt ON r.game_id = grt.game_id AND r.party_id = grt.party_id and r.epoch_id = grt.epoch_id AND r.market_id = grt.market_id ) SELECT * from cte_rewards` args := []interface{}{} - query, args = addRewardWhereClause(query, args, partyIDs, assetIDHex, teamIDHex, gameIDHex, fromEpoch, toEpoch) + query, args = addRewardWhereClause(query, args, partyIDs, assetIDHex, teamIDHex, gameIDHex, fromEpoch, toEpoch, marketID) query, args, err := PaginateQuery[entities.RewardCursor](query, args, rewardsOrdering, pagination) if err != nil { @@ -213,7 +213,7 @@ func (rs *Rewards) GetSummaries(ctx context.Context, ) ([]entities.RewardSummary, error) { query := `SELECT party_id, asset_id, SUM(amount) AS amount FROM rewards` args := []interface{}{} - query, args = addRewardWhereClause(query, args, partyIDs, assetIDHex, nil, nil, nil, nil) + query, args = addRewardWhereClause(query, args, partyIDs, assetIDHex, nil, nil, nil, nil, nil) query = fmt.Sprintf("%s GROUP BY party_id, asset_id ORDER BY party_id", query) summaries := []entities.RewardSummary{} @@ -257,7 +257,7 @@ func (rs *Rewards) GetEpochSummaries(ctx context.Context, // -------------------------------------------- Utility Methods -func addRewardWhereClause(query string, args []interface{}, partyIDs []string, assetIDHex, teamIDHex, gameIDHex *string, fromEpoch, toEpoch *uint64) (string, []interface{}) { +func addRewardWhereClause(query string, args []interface{}, partyIDs []string, assetIDHex, teamIDHex, gameIDHex *string, fromEpoch, toEpoch *uint64, marketID *string) (string, []interface{}) { predicates := []string{} if len(partyIDs) > 0 { @@ -289,6 +289,10 @@ func addRewardWhereClause(query string, args []interface{}, partyIDs []string, a predicates = append(predicates, fmt.Sprintf("epoch_id <= %s", nextBindVar(&args, *toEpoch))) } + if marketID != nil { + predicates = append(predicates, fmt.Sprintf("market_id = %s", nextBindVar(&args, *marketID))) + } + if len(predicates) > 0 { query = fmt.Sprintf("%s WHERE %s", query, strings.Join(predicates, " AND ")) } diff --git a/datanode/sqlstore/rewards_test.go b/datanode/sqlstore/rewards_test.go index c36a04ffe43..7cbc43e9058 100644 --- a/datanode/sqlstore/rewards_test.go +++ b/datanode/sqlstore/rewards_test.go @@ -164,7 +164,7 @@ func TestRewards(t *testing.T) { pagination, err := entities.NewCursorPagination(nil, nil, nil, nil, false) require.NoError(t, err) - actual, _, err := rs.GetByCursor(ctx, []string{party1ID, party2ID}, &asset2ID, nil, nil, pagination, nil, nil) + actual, _, err := rs.GetByCursor(ctx, []string{party1ID, party2ID}, &asset2ID, nil, nil, pagination, nil, nil, nil) require.NoError(t, err) assert.Equal(t, expected, actual) }) @@ -516,7 +516,7 @@ func testRewardsCursorPaginationNoPagination(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 10, len(got)) assert.Equal(t, int64(637), got[0].EpochID) @@ -540,7 +540,7 @@ func testRewardsCursorPaginationFirstPage(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(637), got[0].EpochID) @@ -564,7 +564,7 @@ func testRewardsCursorPaginationLastPage(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(757), got[0].EpochID) @@ -590,7 +590,7 @@ func testRewardsCursorPaginationFirstPageAfter(t *testing.T) { pagination, err := entities.NewCursorPagination(&first, &after, nil, nil, false) require.NoError(t, err) - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(737), got[0].EpochID) @@ -615,7 +615,7 @@ func testRewardsCursorPaginationLastPageBefore(t *testing.T) { before := entities.NewCursor(entities.RewardCursor{PartyID: partyID, AssetID: assetID, EpochID: 757}.String()).Encode() pagination, err := entities.NewCursorPagination(nil, nil, &last, &before, false) require.NoError(t, err) - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(741), got[0].EpochID) @@ -638,7 +638,7 @@ func testRewardsCursorPaginationNoPaginationNewestFirst(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 10, len(got)) assert.Equal(t, int64(1027), got[0].EpochID) @@ -662,7 +662,7 @@ func testRewardsCursorPaginationFirstPageNewestFirst(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(1027), got[0].EpochID) @@ -686,7 +686,7 @@ func testRewardsCursorPaginationLastPageNewestFirst(t *testing.T) { partyID := "89c701d1ae2819263e45538d0b25022988bc2508a02c654462d22e0afb626a7d" assetID := "8aa92225c32adb54e527fcb1aee2930cbadb4df6f068ab2c2d667eb057ef00fa" - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(643), got[0].EpochID) @@ -712,7 +712,7 @@ func testRewardsCursorPaginationFirstPageAfterNewestFirst(t *testing.T) { pagination, err := entities.NewCursorPagination(&first, &after, nil, nil, true) require.NoError(t, err) - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(747), got[0].EpochID) @@ -737,7 +737,7 @@ func testRewardsCursorPaginationLastPageBeforeNewestFirst(t *testing.T) { before := entities.NewCursor(entities.RewardCursor{PartyID: partyID, AssetID: assetID, EpochID: 643}.String()).Encode() pagination, err := entities.NewCursorPagination(nil, nil, &last, &before, true) require.NoError(t, err) - got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil) + got, pageInfo, err := rs.GetByCursor(ctx, []string{partyID}, &assetID, nil, nil, pagination, nil, nil, nil) assert.NoError(t, err) assert.Equal(t, 3, len(got)) assert.Equal(t, int64(744), got[0].EpochID) @@ -1220,7 +1220,7 @@ func TestRewardFilterByTeamIDAndGameID(t *testing.T) { partyID := parties[i] page := entities.DefaultCursorPagination(true) // get the rewards for that party - got, _, err := stores.rewards.GetByCursor(ctx, []string{partyID.String()}, nil, nil, nil, page, nil, nil) + got, _, err := stores.rewards.GetByCursor(ctx, []string{partyID.String()}, nil, nil, nil, page, nil, nil, nil) require.NoError(t, err) want := filterRewardsByParty(rewards, partyID) // we don't care about the ordering as other tests already validate that, we just want to make sure we have all the rewards for the party @@ -1241,7 +1241,7 @@ func TestRewardFilterByTeamIDAndGameID(t *testing.T) { i = r.Intn(len(teams[teamID])) party := teams[teamID][i] page := entities.DefaultCursorPagination(true) - got, _, err := stores.rewards.GetByCursor(ctx, []string{party.ID.String()}, nil, nil, nil, page, ptr.From(teamID), nil) + got, _, err := stores.rewards.GetByCursor(ctx, []string{party.ID.String()}, nil, nil, nil, page, ptr.From(teamID), nil, nil) require.NoError(t, err) want := filterRewardsByParty(filterRewardsByTeam(rewards, entities.TeamID(teamID)), party.ID) assert.ElementsMatchf(t, want, got, "got: %v, want: %v", got, want) @@ -1251,7 +1251,7 @@ func TestRewardFilterByTeamIDAndGameID(t *testing.T) { i := r.Intn(len(gameIDs)) gameID := gameIDs[i] page := entities.DefaultCursorPagination(true) - got, _, err := stores.rewards.GetByCursor(ctx, nil, nil, nil, nil, page, nil, ptr.From(gameID)) + got, _, err := stores.rewards.GetByCursor(ctx, nil, nil, nil, nil, page, nil, ptr.From(gameID), nil) require.NoError(t, err) want := filterRewardsByGame(rewards, entities.GameID(gameID)) assert.ElementsMatchf(t, want, got, "got: %v, want: %v", got, want) diff --git a/go.sum b/go.sum index 0be9f0593ee..4663a648b03 100644 --- a/go.sum +++ b/go.sum @@ -205,8 +205,6 @@ github.com/cockroachdb/pebble v0.0.0-20230209160836-829675f94811/go.mod h1:Nb5lg github.com/cockroachdb/redact v1.1.3 h1:AKZds10rFSIj7qADf0g46UixK8NNLwWTNdCIGS5wfSQ= github.com/cockroachdb/redact v1.1.3/go.mod h1:BVNblN9mBWFyMyqK1k3AAiSxhvhfK2oOZZ2lK+dpvRg= github.com/codegangsta/inject v0.0.0-20150114235600-33e0aa1cb7c0/go.mod h1:4Zcjuz89kmFXt9morQgcfYZAYZ5n8WHjt81YYWIwtTM= -github.com/cometbft/cometbft v0.38.7 h1:ULhIOJ9+LgSy6nLekhq9ae3juX3NnQUMMPyVdhZV6Hk= -github.com/cometbft/cometbft v0.38.7/go.mod h1:HIyf811dFMI73IE0F7RrnY/Fr+d1+HuJAgtkEpQjCMY= github.com/cometbft/cometbft v0.38.8 h1:XyJ9Cu3xqap6xtNxiemrO8roXZ+KS2Zlu7qQ0w1trvU= github.com/cometbft/cometbft v0.38.8/go.mod h1:xOoGZrtUT+A5izWfHSJgl0gYZUE7lu7Z2XIS1vWG/QQ= github.com/cometbft/cometbft-db v0.7.0 h1:uBjbrBx4QzU0zOEnU8KxoDl18dMNgDh+zZRUE0ucsbo= diff --git a/protos/data-node/api/v2/trading_data.pb.go b/protos/data-node/api/v2/trading_data.pb.go index 2d24d804fd9..5f6c8e3661f 100644 --- a/protos/data-node/api/v2/trading_data.pb.go +++ b/protos/data-node/api/v2/trading_data.pb.go @@ -11306,6 +11306,8 @@ type ListRewardsRequest struct { GameId *string `protobuf:"bytes,7,opt,name=game_id,json=gameId,proto3,oneof" json:"game_id,omitempty"` // Whether to return all derived parties from AMMs for the given party. IncludeDerivedParties *bool `protobuf:"varint,8,opt,name=include_derived_parties,json=includeDerivedParties,proto3,oneof" json:"include_derived_parties,omitempty"` + // Filter the rewards by market ID. + MarketId *string `protobuf:"bytes,9,opt,name=market_id,json=marketId,proto3,oneof" json:"market_id,omitempty"` } func (x *ListRewardsRequest) Reset() { @@ -11396,6 +11398,13 @@ func (x *ListRewardsRequest) GetIncludeDerivedParties() bool { return false } +func (x *ListRewardsRequest) GetMarketId() string { + if x != nil && x.MarketId != nil { + return *x.MarketId + } + return "" +} + // Response for listing reward details for a single party type ListRewardsResponse struct { state protoimpl.MessageState @@ -14068,6 +14077,10 @@ type ListPaidLiquidityFeesRequest struct { Pagination *Pagination `protobuf:"bytes,5,opt,name=pagination,proto3,oneof" json:"pagination,omitempty"` // Whether to return all derived parties from AMMs for the given party. If used, party ID is required. IncludeDerivedParties *bool `protobuf:"varint,6,opt,name=include_derived_parties,json=includeDerivedParties,proto3,oneof" json:"include_derived_parties,omitempty"` + // Restrict paid liquidity fees to those from a given epoch. + EpochFrom *uint64 `protobuf:"varint,7,opt,name=epoch_from,json=epochFrom,proto3,oneof" json:"epoch_from,omitempty"` + // Restrict paid liquidity fees to those up to a given epoch. + EpochTo *uint64 `protobuf:"varint,8,opt,name=epoch_to,json=epochTo,proto3,oneof" json:"epoch_to,omitempty"` } func (x *ListPaidLiquidityFeesRequest) Reset() { @@ -14144,6 +14157,20 @@ func (x *ListPaidLiquidityFeesRequest) GetIncludeDerivedParties() bool { return false } +func (x *ListPaidLiquidityFeesRequest) GetEpochFrom() uint64 { + if x != nil && x.EpochFrom != nil { + return *x.EpochFrom + } + return 0 +} + +func (x *ListPaidLiquidityFeesRequest) GetEpochTo() uint64 { + if x != nil && x.EpochTo != nil { + return *x.EpochTo + } + return 0 +} + // Paid liquidity fees response. type ListPaidLiquidityFeesResponse struct { state protoimpl.MessageState @@ -23978,6 +24005,10 @@ type GetFeesStatsRequest struct { EpochSeq *uint64 `protobuf:"varint,3,opt,name=epoch_seq,json=epochSeq,proto3,oneof" json:"epoch_seq,omitempty"` // Restrict fee statistics to those for the given party. PartyId *string `protobuf:"bytes,4,opt,name=party_id,json=partyId,proto3,oneof" json:"party_id,omitempty"` + // Restrict fee statistics to epoch range starting with epoch from. + EpochFrom *uint64 `protobuf:"varint,5,opt,name=epoch_from,json=epochFrom,proto3,oneof" json:"epoch_from,omitempty"` + // Restrict fee statistics to epoch range ending with epoch to. + EpochTo *uint64 `protobuf:"varint,6,opt,name=epoch_to,json=epochTo,proto3,oneof" json:"epoch_to,omitempty"` } func (x *GetFeesStatsRequest) Reset() { @@ -24040,6 +24071,20 @@ func (x *GetFeesStatsRequest) GetPartyId() string { return "" } +func (x *GetFeesStatsRequest) GetEpochFrom() uint64 { + if x != nil && x.EpochFrom != nil { + return *x.EpochFrom + } + return 0 +} + +func (x *GetFeesStatsRequest) GetEpochTo() uint64 { + if x != nil && x.EpochTo != nil { + return *x.EpochTo + } + return 0 +} + // Response that is sent when requesting fees statistics. type GetFeesStatsResponse struct { state protoimpl.MessageState @@ -28484,7 +28529,7 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x12, 0x36, 0x0a, 0x09, 0x70, 0x61, 0x67, 0x65, 0x5f, 0x69, 0x6e, 0x66, 0x6f, 0x18, 0x02, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x50, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x52, 0x08, - 0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xba, 0x03, 0x0a, 0x12, 0x4c, 0x69, 0x73, + 0x70, 0x61, 0x67, 0x65, 0x49, 0x6e, 0x66, 0x6f, 0x22, 0xea, 0x03, 0x0a, 0x12, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x19, 0x0a, 0x08, 0x70, 0x61, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x52, 0x07, 0x70, 0x61, 0x72, 0x74, 0x79, 0x49, 0x64, 0x12, 0x1e, 0x0a, 0x08, 0x61, 0x73, @@ -28505,14 +28550,17 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x08, 0x20, 0x01, 0x28, 0x08, 0x48, 0x06, 0x52, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x44, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x50, - 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x61, 0x73, - 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, - 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x5f, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x74, 0x6f, 0x5f, 0x65, 0x70, 0x6f, 0x63, - 0x68, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x42, 0x0a, 0x0a, - 0x08, 0x5f, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x42, 0x1a, 0x0a, 0x18, 0x5f, 0x69, 0x6e, - 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x70, 0x61, - 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x53, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x77, + 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x20, 0x0a, 0x09, 0x6d, 0x61, 0x72, + 0x6b, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x09, 0x20, 0x01, 0x28, 0x09, 0x48, 0x07, 0x52, 0x08, + 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, 0x0b, 0x0a, 0x09, 0x5f, + 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, + 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x66, 0x72, 0x6f, 0x6d, + 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x74, 0x6f, 0x5f, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x42, 0x0a, 0x0a, 0x08, 0x5f, 0x74, 0x65, 0x61, 0x6d, 0x5f, 0x69, 0x64, 0x42, + 0x0a, 0x0a, 0x08, 0x5f, 0x67, 0x61, 0x6d, 0x65, 0x5f, 0x69, 0x64, 0x42, 0x1a, 0x0a, 0x18, 0x5f, + 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x5f, + 0x70, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x6d, 0x61, 0x72, 0x6b, + 0x65, 0x74, 0x5f, 0x69, 0x64, 0x22, 0x53, 0x0a, 0x13, 0x4c, 0x69, 0x73, 0x74, 0x52, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x3c, 0x0a, 0x07, 0x72, 0x65, 0x77, 0x61, 0x72, 0x64, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x22, 0x2e, 0x64, 0x61, 0x74, 0x61, 0x6e, 0x6f, 0x64, 0x65, 0x2e, 0x61, 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, @@ -28883,7 +28931,7 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x70, 0x69, 0x2e, 0x76, 0x32, 0x2e, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, 0x69, 0x64, 0x65, 0x72, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x6c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x50, 0x72, 0x6f, 0x76, - 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0xf2, 0x02, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, + 0x69, 0x64, 0x65, 0x72, 0x73, 0x22, 0xd2, 0x03, 0x0a, 0x1c, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x69, 0x64, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x46, 0x65, 0x65, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x09, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x6d, 0x61, 0x72, @@ -28901,12 +28949,18 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x18, 0x06, 0x20, 0x01, 0x28, 0x08, 0x48, 0x04, 0x52, 0x15, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x44, 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x50, 0x61, 0x72, 0x74, - 0x69, 0x65, 0x73, 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x6d, 0x61, 0x72, 0x6b, 0x65, - 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, - 0x64, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x65, 0x71, 0x42, - 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, 0x6f, 0x6e, 0x42, 0x1a, - 0x0a, 0x18, 0x5f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, 0x65, 0x72, 0x69, 0x76, - 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x22, 0x7d, 0x0a, 0x1d, 0x4c, 0x69, + 0x69, 0x65, 0x73, 0x88, 0x01, 0x01, 0x12, 0x22, 0x0a, 0x0a, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, + 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x07, 0x20, 0x01, 0x28, 0x04, 0x48, 0x05, 0x52, 0x09, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x46, 0x72, 0x6f, 0x6d, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x08, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x5f, 0x74, 0x6f, 0x18, 0x08, 0x20, 0x01, 0x28, 0x04, 0x48, 0x06, 0x52, 0x07, + 0x65, 0x70, 0x6f, 0x63, 0x68, 0x54, 0x6f, 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x6d, + 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x61, 0x73, 0x73, + 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, + 0x73, 0x65, 0x71, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x70, 0x61, 0x67, 0x69, 0x6e, 0x61, 0x74, 0x69, + 0x6f, 0x6e, 0x42, 0x1a, 0x0a, 0x18, 0x5f, 0x69, 0x6e, 0x63, 0x6c, 0x75, 0x64, 0x65, 0x5f, 0x64, + 0x65, 0x72, 0x69, 0x76, 0x65, 0x64, 0x5f, 0x70, 0x61, 0x72, 0x74, 0x69, 0x65, 0x73, 0x42, 0x0d, + 0x0a, 0x0b, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x42, 0x0b, 0x0a, + 0x09, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x74, 0x6f, 0x22, 0x7d, 0x0a, 0x1d, 0x4c, 0x69, 0x73, 0x74, 0x50, 0x61, 0x69, 0x64, 0x4c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x46, 0x65, 0x65, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x5c, 0x0a, 0x13, 0x70, 0x61, 0x69, 0x64, 0x5f, 0x6c, 0x69, 0x71, 0x75, 0x69, 0x64, 0x69, 0x74, 0x79, 0x5f, 0x66, 0x65, @@ -30413,7 +30467,7 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x76, 0x32, 0x2e, 0x54, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x65, 0x48, 0x69, 0x73, 0x74, 0x6f, 0x72, 0x79, 0x43, 0x6f, 0x6e, 0x6e, 0x65, 0x63, 0x74, 0x69, 0x6f, 0x6e, 0x52, 0x12, 0x74, 0x65, 0x61, 0x6d, 0x52, 0x65, 0x66, 0x65, 0x72, 0x65, 0x65, 0x48, 0x69, 0x73, 0x74, - 0x6f, 0x72, 0x79, 0x22, 0xcf, 0x01, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x73, 0x53, + 0x6f, 0x72, 0x79, 0x22, 0xaf, 0x02, 0x0a, 0x13, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x71, 0x75, 0x65, 0x73, 0x74, 0x12, 0x20, 0x0a, 0x09, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x18, 0x01, 0x20, 0x01, 0x28, 0x09, 0x48, 0x00, 0x52, 0x08, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, @@ -30422,11 +30476,17 @@ var file_data_node_api_v2_trading_data_proto_rawDesc = []byte{ 0x09, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x65, 0x71, 0x18, 0x03, 0x20, 0x01, 0x28, 0x04, 0x48, 0x02, 0x52, 0x08, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x53, 0x65, 0x71, 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x08, 0x70, 0x61, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x18, 0x04, 0x20, 0x01, 0x28, - 0x09, 0x48, 0x03, 0x52, 0x07, 0x70, 0x61, 0x72, 0x74, 0x79, 0x49, 0x64, 0x88, 0x01, 0x01, 0x42, - 0x0c, 0x0a, 0x0a, 0x5f, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0b, 0x0a, - 0x09, 0x5f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x65, - 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x65, 0x71, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x70, 0x61, 0x72, - 0x74, 0x79, 0x5f, 0x69, 0x64, 0x22, 0x50, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x73, + 0x09, 0x48, 0x03, 0x52, 0x07, 0x70, 0x61, 0x72, 0x74, 0x79, 0x49, 0x64, 0x88, 0x01, 0x01, 0x12, + 0x22, 0x0a, 0x0a, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x18, 0x05, 0x20, + 0x01, 0x28, 0x04, 0x48, 0x04, 0x52, 0x09, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x46, 0x72, 0x6f, 0x6d, + 0x88, 0x01, 0x01, 0x12, 0x1e, 0x0a, 0x08, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x74, 0x6f, 0x18, + 0x06, 0x20, 0x01, 0x28, 0x04, 0x48, 0x05, 0x52, 0x07, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x54, 0x6f, + 0x88, 0x01, 0x01, 0x42, 0x0c, 0x0a, 0x0a, 0x5f, 0x6d, 0x61, 0x72, 0x6b, 0x65, 0x74, 0x5f, 0x69, + 0x64, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x61, 0x73, 0x73, 0x65, 0x74, 0x5f, 0x69, 0x64, 0x42, 0x0c, + 0x0a, 0x0a, 0x5f, 0x65, 0x70, 0x6f, 0x63, 0x68, 0x5f, 0x73, 0x65, 0x71, 0x42, 0x0b, 0x0a, 0x09, + 0x5f, 0x70, 0x61, 0x72, 0x74, 0x79, 0x5f, 0x69, 0x64, 0x42, 0x0d, 0x0a, 0x0b, 0x5f, 0x65, 0x70, + 0x6f, 0x63, 0x68, 0x5f, 0x66, 0x72, 0x6f, 0x6d, 0x42, 0x0b, 0x0a, 0x09, 0x5f, 0x65, 0x70, 0x6f, + 0x63, 0x68, 0x5f, 0x74, 0x6f, 0x22, 0x50, 0x0a, 0x14, 0x47, 0x65, 0x74, 0x46, 0x65, 0x65, 0x73, 0x53, 0x74, 0x61, 0x74, 0x73, 0x52, 0x65, 0x73, 0x70, 0x6f, 0x6e, 0x73, 0x65, 0x12, 0x38, 0x0a, 0x0a, 0x66, 0x65, 0x65, 0x73, 0x5f, 0x73, 0x74, 0x61, 0x74, 0x73, 0x18, 0x01, 0x20, 0x01, 0x28, 0x0b, 0x32, 0x19, 0x2e, 0x76, 0x65, 0x67, 0x61, 0x2e, 0x65, 0x76, 0x65, 0x6e, 0x74, 0x73, 0x2e, diff --git a/protos/sources/data-node/api/v2/trading_data.proto b/protos/sources/data-node/api/v2/trading_data.proto index 256ca1072f5..079f7d5802a 100644 --- a/protos/sources/data-node/api/v2/trading_data.proto +++ b/protos/sources/data-node/api/v2/trading_data.proto @@ -2725,6 +2725,8 @@ message ListRewardsRequest { optional string game_id = 7; // Whether to return all derived parties from AMMs for the given party. optional bool include_derived_parties = 8; + // Filter the rewards by market ID. + optional string market_id = 9; } // Response for listing reward details for a single party @@ -3117,6 +3119,10 @@ message ListPaidLiquidityFeesRequest { optional Pagination pagination = 5; // Whether to return all derived parties from AMMs for the given party. If used, party ID is required. optional bool include_derived_parties = 6; + // Restrict paid liquidity fees to those from a given epoch. + optional uint64 epoch_from = 7; + // Restrict paid liquidity fees to those up to a given epoch. + optional uint64 epoch_to = 8; } // Paid liquidity fees response. @@ -4596,6 +4602,10 @@ message GetFeesStatsRequest { optional uint64 epoch_seq = 3; // Restrict fee statistics to those for the given party. optional string party_id = 4; + // Restrict fee statistics to epoch range starting with epoch from. + optional uint64 epoch_from = 5; + // Restrict fee statistics to epoch range ending with epoch to. + optional uint64 epoch_to = 6; } // Response that is sent when requesting fees statistics.