diff --git a/core/volumediscount/engine.go b/core/volumediscount/engine.go index 971e9adf6f..a97224519e 100644 --- a/core/volumediscount/engine.go +++ b/core/volumediscount/engine.go @@ -210,9 +210,9 @@ func (e *Engine) computeFactorsByParty(ctx context.Context, epoch uint64) { // if the party hasn't qualified, then still send the stats but with a zero factor if !qualifiedForTier { evt.Stats = append(evt.Stats, &eventspb.PartyVolumeDiscountStats{ - PartyId: party.String(), - DiscountFactor: "0", - RunningVolume: notionalVolume.Round(0).String(), + PartyId: party.String(), + DiscountFactors: types.EmptyFactors.IntoDiscountFactorsProto(), + RunningVolume: notionalVolume.Round(0).String(), }) } } diff --git a/core/volumediscount/helpers_for_test.go b/core/volumediscount/helpers_for_test.go index 75cfde13e2..1a70382ec8 100644 --- a/core/volumediscount/helpers_for_test.go +++ b/core/volumediscount/helpers_for_test.go @@ -79,7 +79,7 @@ func expectStatsUpdatedWithUnqualifiedParties(t *testing.T, broker *mocks.MockBr for _, s := range stats.Stats { if s.PartyId == "p1" { foundUnqualifiedParty = true - require.Equal(t, "0", s.DiscountFactor) + require.Equal(t, "", s.DiscountFactor) require.Equal(t, "900", s.RunningVolume) } } diff --git a/datanode/sqlstore/referral_programs_test.go b/datanode/sqlstore/referral_programs_test.go index 6d1cdf3935..4c239c8cd9 100644 --- a/datanode/sqlstore/referral_programs_test.go +++ b/datanode/sqlstore/referral_programs_test.go @@ -60,12 +60,32 @@ func TestReferralPrograms_AddReferralProgram(t *testing.T) { MinimumEpochs: "10", ReferralRewardFactor: "0.0001", ReferralDiscountFactor: "0.0001", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.00002", + LiquidityRewardFactor: "0.00004", + MakerRewardFactor: "0.00004", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.00002", + LiquidityDiscountFactor: "0.00004", + MakerDiscountFactor: "0.00004", + }, }, { MinimumRunningNotionalTakerVolume: "10000", MinimumEpochs: "100", ReferralRewardFactor: "0.001", ReferralDiscountFactor: "0.001", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.0002", + LiquidityRewardFactor: "0.0004", + MakerRewardFactor: "0.0004", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.0002", + LiquidityDiscountFactor: "0.0004", + MakerDiscountFactor: "0.0004", + }, }, }, EndOfProgramTimestamp: endTime.Unix(), @@ -92,12 +112,32 @@ func TestReferralPrograms_AddReferralProgram(t *testing.T) { MinimumEpochs: "20", ReferralRewardFactor: "0.0002", ReferralDiscountFactor: "0.0002", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.00004", + LiquidityRewardFactor: "0.00008", + MakerRewardFactor: "0.00008", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.00004", + LiquidityDiscountFactor: "0.00008", + MakerDiscountFactor: "0.00008", + }, }, { MinimumRunningNotionalTakerVolume: "20000", MinimumEpochs: "200", ReferralRewardFactor: "0.002", ReferralDiscountFactor: "0.002", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.0004", + LiquidityRewardFactor: "0.0008", + MakerRewardFactor: "0.0008", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.0004", + LiquidityDiscountFactor: "0.0008", + MakerDiscountFactor: "0.0008", + }, }, }, EndOfProgramTimestamp: endTime2.Unix(), @@ -153,12 +193,32 @@ func getReferralEvents(t *testing.T, endTime time.Time) (*eventspb.ReferralProgr MinimumEpochs: "10", ReferralRewardFactor: "0.0001", ReferralDiscountFactor: "0.0001", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.00002", + LiquidityRewardFactor: "0.00004", + MakerRewardFactor: "0.00004", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.00002", + LiquidityDiscountFactor: "0.00004", + MakerDiscountFactor: "0.00004", + }, }, { MinimumRunningNotionalTakerVolume: "10000", MinimumEpochs: "100", ReferralRewardFactor: "0.001", ReferralDiscountFactor: "0.001", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.0002", + LiquidityRewardFactor: "0.0004", + MakerRewardFactor: "0.0004", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.0002", + LiquidityDiscountFactor: "0.0004", + MakerDiscountFactor: "0.0004", + }, }, }, EndOfProgramTimestamp: endTime.Unix(), @@ -188,12 +248,32 @@ func getReferralEvents(t *testing.T, endTime time.Time) (*eventspb.ReferralProgr MinimumEpochs: "20", ReferralRewardFactor: "0.0002", ReferralDiscountFactor: "0.0002", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.0004", + LiquidityRewardFactor: "0.0008", + MakerRewardFactor: "0.0008", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.0004", + LiquidityDiscountFactor: "0.0008", + MakerDiscountFactor: "0.0008", + }, }, { MinimumRunningNotionalTakerVolume: "20000", MinimumEpochs: "200", ReferralRewardFactor: "0.002", ReferralDiscountFactor: "0.002", + ReferralRewardFactors: &vega.RewardFactors{ + InfrastructureRewardFactor: "0.004", + LiquidityRewardFactor: "0.008", + MakerRewardFactor: "0.008", + }, + ReferralDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.004", + LiquidityDiscountFactor: "0.008", + MakerDiscountFactor: "0.008", + }, }, }, EndOfProgramTimestamp: endTime.Unix(), diff --git a/datanode/sqlstore/volume_discount_programs_test.go b/datanode/sqlstore/volume_discount_programs_test.go index 22e3058f2e..54988720af 100644 --- a/datanode/sqlstore/volume_discount_programs_test.go +++ b/datanode/sqlstore/volume_discount_programs_test.go @@ -58,10 +58,20 @@ func TestVolumeDiscountPrograms_AddVolumeDiscountProgram(t *testing.T) { { MinimumRunningNotionalTakerVolume: "1000", VolumeDiscountFactor: "0.01", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.004", + LiquidityDiscountFactor: "0.002", + MakerDiscountFactor: "0.004", + }, }, { MinimumRunningNotionalTakerVolume: "10000", VolumeDiscountFactor: "0.1", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.04", + LiquidityDiscountFactor: "0.02", + MakerDiscountFactor: "0.04", + }, }, }, EndOfProgramTimestamp: endTime.Unix(), @@ -76,10 +86,20 @@ func TestVolumeDiscountPrograms_AddVolumeDiscountProgram(t *testing.T) { { MinimumRunningNotionalTakerVolume: "2000", VolumeDiscountFactor: "0.02", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.008", + LiquidityDiscountFactor: "0.002", + MakerDiscountFactor: "0.004", + }, }, { MinimumRunningNotionalTakerVolume: "20000", VolumeDiscountFactor: "0.2", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.08", + LiquidityDiscountFactor: "0.04", + MakerDiscountFactor: "0.08", + }, }, }, EndOfProgramTimestamp: endTime2.Unix(), @@ -122,10 +142,20 @@ func getVolumeDiscountEvents(t *testing.T, endTime time.Time) (*eventspb.VolumeD { MinimumRunningNotionalTakerVolume: "1000", VolumeDiscountFactor: "0.01", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.004", + LiquidityDiscountFactor: "0.002", + MakerDiscountFactor: "0.004", + }, }, { MinimumRunningNotionalTakerVolume: "10000", VolumeDiscountFactor: "0.1", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.04", + LiquidityDiscountFactor: "0.02", + MakerDiscountFactor: "0.04", + }, }, }, EndOfProgramTimestamp: endTime.Unix(), @@ -143,10 +173,20 @@ func getVolumeDiscountEvents(t *testing.T, endTime time.Time) (*eventspb.VolumeD { MinimumRunningNotionalTakerVolume: "2000", VolumeDiscountFactor: "0.02", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.008", + LiquidityDiscountFactor: "0.004", + MakerDiscountFactor: "0.008", + }, }, { MinimumRunningNotionalTakerVolume: "20000", VolumeDiscountFactor: "0.2", + VolumeDiscountFactors: &vega.DiscountFactors{ + InfrastructureDiscountFactor: "0.08", + LiquidityDiscountFactor: "0.04", + MakerDiscountFactor: "0.08", + }, }, }, EndOfProgramTimestamp: endTime.Unix(),