Skip to content

Commit

Permalink
Merge branch 'develop' into reward_scaling
Browse files Browse the repository at this point in the history
  • Loading branch information
ze97286 authored Aug 29, 2024
2 parents a9f86bb + f1e6e81 commit 0c92a4a
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 29 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
18 changes: 18 additions & 0 deletions commands/transfer_funds.go
Original file line number Diff line number Diff line change
Expand Up @@ -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"))
Expand Down
34 changes: 5 additions & 29 deletions commands/transfer_funds_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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: &notionalVolumeValid,
},
},
},
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,
Expand Down Expand Up @@ -1598,6 +1571,9 @@ func TestTransferFunds(t *testing.T) {
WindowLength: 100,
TransferInterval: &tooLongTransferInterval,
TargetNotionalVolume: &notionalVolumeValid,
DistributionStrategy: vega.DistributionStrategy_DISTRIBUTION_STRATEGY_PRO_RATA,
EntityScope: vega.EntityScope_ENTITY_SCOPE_TEAMS,

Check failure on line 1575 in commands/transfer_funds_test.go

View workflow job for this annotation

GitHub Actions / lint

duplicate field name EntityScope in struct literal (typecheck)
// no asset for metric, no markets in scope, no position requirement, no staking requirement
},
},
},
Expand All @@ -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)",
},
}

Expand Down

0 comments on commit 0c92a4a

Please sign in to comment.