Skip to content

Commit

Permalink
Merge branch 'develop' into 11533
Browse files Browse the repository at this point in the history
  • Loading branch information
ze97286 authored Aug 15, 2024
2 parents f6e5a6b + 678c909 commit 5adca9e
Show file tree
Hide file tree
Showing 4 changed files with 124 additions and 4 deletions.
6 changes: 3 additions & 3 deletions core/volumediscount/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion core/volumediscount/helpers_for_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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)
}
}
Expand Down
80 changes: 80 additions & 0 deletions datanode/sqlstore/referral_programs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down Expand Up @@ -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(),
Expand Down
40 changes: 40 additions & 0 deletions datanode/sqlstore/volume_discount_programs_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down Expand Up @@ -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(),
Expand All @@ -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(),
Expand Down

0 comments on commit 5adca9e

Please sign in to comment.