diff --git a/CHANGELOG.md b/CHANGELOG.md index b3327cf56b..82aec40833 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - [11577](https://github.com/vegaprotocol/vega/issues/11577) - Add API for party discounts and rewards. - [10716](https://github.com/vegaprotocol/vega/issues/10716) - Set Tendermint defaults during init. - [11612](https://github.com/vegaprotocol/vega/issues/11612) - Reward scaling support. +-[11624](https://github.com/vegaprotocol/vega/issues/11624) - prevent creation of rewards with no payout, but with high computational cost. ### 🐛 Fixes diff --git a/commands/transfer_funds.go b/commands/transfer_funds.go index cf32c059a0..b8c6402cf1 100644 --- a/commands/transfer_funds.go +++ b/commands/transfer_funds.go @@ -243,6 +243,24 @@ func validateDispatchStrategy(toAccountType vega.AccountType, dispatchStrategy * if dispatchStrategy.EntityScope == vega.EntityScope_ENTITY_SCOPE_TEAMS && len(dispatchStrategy.NTopPerformers) == 0 { errs.AddForProperty(prefix+".n_top_performers", ErrIsRequired) } + if dispatchStrategy.Metric == vega.DispatchMetric_DISPATCH_METRIC_ELIGIBLE_ENTITIES { + var metricAssetDefined, marketScope, stakingRequirement, positionRequirement bool + if len(dispatchStrategy.AssetForMetric) > 0 { + metricAssetDefined = true + } + if len(dispatchStrategy.Markets) > 0 { + marketScope = true + } + if len(dispatchStrategy.StakingRequirement) > 0 { + stakingRequirement = true + } + if len(dispatchStrategy.NotionalTimeWeightedAveragePositionRequirement) > 0 { + positionRequirement = true + } + if !metricAssetDefined && !marketScope && !stakingRequirement && !positionRequirement { + errs.AddForProperty(prefix+".dispatch_metric", fmt.Errorf("eligible_entities metric requires at least one of (markets, asset_for_metric, staking_requirement, notional_time_weighted_average_position_requirement) to be defined")) + } + } if dispatchStrategy.Metric == vega.DispatchMetric_DISPATCH_METRIC_ELIGIBLE_ENTITIES && len(dispatchStrategy.NotionalTimeWeightedAveragePositionRequirement) > 0 && len(dispatchStrategy.AssetForMetric) == 0 { errs.AddForProperty(prefix+".asset_for_metric", fmt.Errorf("asset for metric must be provided if NotionalTimeWeightedAveragePositionRequirement is specified")) diff --git a/commands/transfer_funds_test.go b/commands/transfer_funds_test.go index 7498d9350c..3aa6aa01bc 100644 --- a/commands/transfer_funds_test.go +++ b/commands/transfer_funds_test.go @@ -1526,34 +1526,7 @@ func TestTransferFunds(t *testing.T) { Reference: "testing", }, errString: "transfer.kind.dispatch_strategy.target_notional_volume (must be positive)", - }, - { - transfer: commandspb.Transfer{ - FromAccountType: vega.AccountType_ACCOUNT_TYPE_GENERAL, - ToAccountType: vega.AccountType_ACCOUNT_TYPE_REWARD_ELIGIBLE_ENTITIES, - Kind: &commandspb.Transfer_Recurring{ - Recurring: &commandspb.RecurringTransfer{ - StartEpoch: 10, - EndEpoch: ptr.From(uint64(11)), - Factor: "1", - DispatchStrategy: &vega.DispatchStrategy{ - AssetForMetric: "", - Metric: vega.DispatchMetric_DISPATCH_METRIC_ELIGIBLE_ENTITIES, - EntityScope: vega.EntityScope_ENTITY_SCOPE_INDIVIDUALS, - IndividualScope: vega.IndividualScope_INDIVIDUAL_SCOPE_IN_TEAM, - WindowLength: 100, - TransferInterval: &tooLongTransferInterval, - TargetNotionalVolume: ¬ionalVolumeValid, - }, - }, - }, - To: "84e2b15102a8d6c1c6b4bdf40af8a0dc21b040eaaa1c94cd10d17604b75fdc35", - Asset: "080538b7cc2249de568cb4272a17f4d5e0b0a69a1a240acbf5119d816178daff", - Amount: "1", - Reference: "testing", - }, - errString: "transfer.kind.dispatch_strategy.target_notional_volume (not allowed for metric DISPATCH_METRIC_ELIGIBLE_ENTITIES)", - }, + }, { transfer: commandspb.Transfer{ FromAccountType: vega.AccountType_ACCOUNT_TYPE_GENERAL, @@ -1598,6 +1571,9 @@ func TestTransferFunds(t *testing.T) { WindowLength: 100, TransferInterval: &tooLongTransferInterval, TargetNotionalVolume: ¬ionalVolumeValid, + DistributionStrategy: vega.DistributionStrategy_DISTRIBUTION_STRATEGY_PRO_RATA, + EntityScope: vega.EntityScope_ENTITY_SCOPE_TEAMS, + // no asset for metric, no markets in scope, no position requirement, no staking requirement }, }, }, @@ -1606,7 +1582,7 @@ func TestTransferFunds(t *testing.T) { Amount: "1", Reference: "testing", }, - errString: "transfer.kind.dispatch_strategy.target_notional_volume (not allowed for metric DISPATCH_METRIC_VALIDATOR_RANKING)", + errString: "transfer.kind.dispatch_strategy.dispatch_metric (eligible_entities metric requires at least one of (markets, asset_for_metric, staking_requirement, notional_time_weighted_average_position_requirement) to be defined)", }, }