Skip to content

Commit

Permalink
Merge pull request #11670 from vegaprotocol/feature/windowLenght-prog…
Browse files Browse the repository at this point in the history
…rams

feat: set max program window lenghts to 200
  • Loading branch information
jeremyletang authored Sep 12, 2024
2 parents 1faa950 + 8e1bb4d commit b31dff0
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 10 deletions.
1 change: 1 addition & 0 deletions commands/errors.go
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@ var (
ErrMustBeLessThan150 = errors.New("must be less than 150")
ErrMustBeAtMost1M = errors.New("must be at most 1000000")
ErrMustBeAtMost100 = errors.New("must be at most 100")
ErrMustBeAtMost200 = errors.New("must be at most 200")
ErrMustBeAtMost2048 = errors.New("must be at most 2048")
ErrMustBeWithinRange7 = errors.New("must be between -7 and 7")
ErrIsNotValid = errors.New("is not a valid value")
Expand Down
12 changes: 6 additions & 6 deletions commands/proposal_submission.go
Original file line number Diff line number Diff line change
Expand Up @@ -385,8 +385,8 @@ func checkReferralProgramChanges(changes *vegapb.ReferralProgramChanges, enactme
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_referral_program.changes.window_length", ErrMustBeAtMost200)
}

tiers := map[string]struct{}{}
Expand Down Expand Up @@ -449,8 +449,8 @@ func checkVolumeRebateProgramChanges(changes *vegapb.VolumeRebateProgramChanges,
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_volume_rebate_program.changes.window_length", ErrMustBeAtMost200)
}
for i, tier := range changes.BenefitTiers {
errs.Merge(checkVolumeRebateBenefitTier(i, tier))
Expand Down Expand Up @@ -497,8 +497,8 @@ func checkVolumeDiscountProgramChanges(changes *vegapb.VolumeDiscountProgramChan
}
if changes.WindowLength == 0 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrIsRequired)
} else if changes.WindowLength > 100 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrMustBeAtMost100)
} else if changes.WindowLength > 200 {
errs.AddForProperty("update_volume_discount_program.changes.window_length", ErrMustBeAtMost200)
}
for i, tier := range changes.BenefitTiers {
errs.Merge(checkVolumeBenefitTier(i, tier))
Expand Down
4 changes: 2 additions & 2 deletions commands/proposal_submission_update_referral_program_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -149,14 +149,14 @@ func testSubmissionForReferralProgramUpdateWithWindowLengthOverLimitFails(t *tes
Change: &types.ProposalTerms_UpdateReferralProgram{
UpdateReferralProgram: &types.UpdateReferralProgram{
Changes: &types.ReferralProgramChanges{
WindowLength: 101,
WindowLength: 201,
},
},
},
},
})

assert.Contains(t, err.Get("proposal_submission.terms.change.update_referral_program.changes.window_length"), commands.ErrMustBeAtMost100)
assert.Contains(t, err.Get("proposal_submission.terms.change.update_referral_program.changes.window_length"), commands.ErrMustBeAtMost200)
}

func testSubmissionForReferralProgramUpdateWithoutTierMinimumRunningNotionalTakerVolumeFails(t *testing.T) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -134,14 +134,14 @@ func testSubmissionForVolumeDiscountProgramUpdateWithWindowLengthOverLimitFails(
Change: &types.ProposalTerms_UpdateVolumeDiscountProgram{
UpdateVolumeDiscountProgram: &types.UpdateVolumeDiscountProgram{
Changes: &types.VolumeDiscountProgramChanges{
WindowLength: 101,
WindowLength: 201,
},
},
},
},
})

assert.Contains(t, err.Get("proposal_submission.terms.change.update_volume_discount_program.changes.window_length"), commands.ErrMustBeAtMost100)
assert.Contains(t, err.Get("proposal_submission.terms.change.update_volume_discount_program.changes.window_length"), commands.ErrMustBeAtMost200)
}

func testSubmissionForVolumeDiscountProgramUpdateWithoutTierMinimumRunningNotionalTakerVolumeFails(t *testing.T) {
Expand Down

0 comments on commit b31dff0

Please sign in to comment.