From 592a6bd69be6a9aa6780cc74280408566134f8e4 Mon Sep 17 00:00:00 2001 From: Jeremy Letang Date: Tue, 27 Feb 2024 10:47:52 +0000 Subject: [PATCH] fix: allow for a 0 funding rate scaling factor Signed-off-by: Jeremy Letang --- CHANGELOG.md | 11 ++++++----- commands/proposal_submission.go | 8 ++++---- commands/proposal_submission_new_market_test.go | 9 +-------- commands/proposal_submission_update_market_test.go | 9 +-------- 4 files changed, 12 insertions(+), 25 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 8938b6a5494..c235a5f5945 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -20,13 +20,14 @@ - [10722](https://github.com/vegaprotocol/vega/issues/10722) - Team API aggregation does not aggregate from the latest epoch. - [10743](https://github.com/vegaprotocol/vega/issues/10722) - When SLA hysteresis epochs are updated resize the ring using new value. - [10725](https://github.com/vegaprotocol/vega/issues/10725) - Batch proposal votes to contain `ELS` per market. -- [10744](https://github.com/vegaprotocol/vega/issues/10744) - Prevent governance suspension of a market already governance suspended. +- [10744](https://github.com/vegaprotocol/vega/issues/10744) - Prevent governance suspension of a market already governance suspended. - [10374](https://github.com/vegaprotocol/vega/issues/10374) - Ledger entries did not return data when filtering by transfer id. -- [10750](https://github.com/vegaprotocol/vega/issues/10750) - Handle cancellation of order on entering auction for party in isolated margin mode. -- [10748](https://github.com/vegaprotocol/vega/issues/10748) - Ensure apply fees cannot fail. -- [10752](https://github.com/vegaprotocol/vega/issues/10752) - Handle amend in place correctly for failure in isolated margin check. -- [10753](https://github.com/vegaprotocol/vega/issues/10753) - Handle the case that a submitted order is `FoK` in isolated margin to not double discount it from position. +- [10750](https://github.com/vegaprotocol/vega/issues/10750) - Handle cancellation of order on entering auction for party in isolated margin mode. +- [10748](https://github.com/vegaprotocol/vega/issues/10748) - Ensure apply fees cannot fail. +- [10752](https://github.com/vegaprotocol/vega/issues/10752) - Handle amend in place correctly for failure in isolated margin check. +- [10753](https://github.com/vegaprotocol/vega/issues/10753) - Handle the case that a submitted order is `FoK` in isolated margin to not double discount it from position. - [10136](https://github.com/vegaprotocol/vega/issues/10136) - Assure opening auction uncrossing price gets registered in the perps engine. +- [10727](https://github.com/vegaprotocol/vega/issues/10727) - Allow for a 0 funding rate scaling factor. ## 0.74.3 diff --git a/commands/proposal_submission.go b/commands/proposal_submission.go index a3dd94818d8..3d67bb074fc 100644 --- a/commands/proposal_submission.go +++ b/commands/proposal_submission.go @@ -1253,8 +1253,8 @@ func checkNewPerps(perps *protoTypes.PerpetualProduct, parentProperty string) Er if err != nil { errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrIsNotValidNumber) } - if !sf.IsPositive() { - errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrMustBePositive) + if sf.IsNegative() { + errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrMustBePositiveOrZero) } } @@ -1402,8 +1402,8 @@ func checkUpdatePerps(perps *protoTypes.UpdatePerpetualProduct, parentProperty s if err != nil { errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrIsNotValidNumber) } - if !sf.IsPositive() { - errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrMustBePositive) + if sf.IsNegative() { + errs.AddForProperty(fmt.Sprintf("%s.perps.funding_rate_scaling_factor", parentProperty), ErrMustBePositiveOrZero) } } diff --git a/commands/proposal_submission_new_market_test.go b/commands/proposal_submission_new_market_test.go index 18b047d6449..c1500810907 100644 --- a/commands/proposal_submission_new_market_test.go +++ b/commands/proposal_submission_new_market_test.go @@ -5175,14 +5175,7 @@ func testNewPerpsMarketWithFundingRateModifiers(t *testing.T) { FundingRateScalingFactor: ptr.From("-10"), }, path: "proposal_submission.terms.change.new_market.changes.instrument.product.perps.funding_rate_scaling_factor", - err: commands.ErrMustBePositive, - }, - { - product: vegapb.PerpetualProduct{ - FundingRateScalingFactor: ptr.From("0"), - }, - path: "proposal_submission.terms.change.new_market.changes.instrument.product.perps.funding_rate_scaling_factor", - err: commands.ErrMustBePositive, + err: commands.ErrMustBePositiveOrZero, }, { product: vegapb.PerpetualProduct{ diff --git a/commands/proposal_submission_update_market_test.go b/commands/proposal_submission_update_market_test.go index 781a08ed78d..2b1fa900336 100644 --- a/commands/proposal_submission_update_market_test.go +++ b/commands/proposal_submission_update_market_test.go @@ -3489,14 +3489,7 @@ func testUpdatePerpetualMarketWithFundingRateModifiers(t *testing.T) { FundingRateScalingFactor: ptr.From("-10"), }, path: "proposal_submission.terms.change.update_market.changes.instrument.product.perps.funding_rate_scaling_factor", - err: commands.ErrMustBePositive, - }, - { - product: vegapb.UpdatePerpetualProduct{ - FundingRateScalingFactor: ptr.From("0"), - }, - path: "proposal_submission.terms.change.update_market.changes.instrument.product.perps.funding_rate_scaling_factor", - err: commands.ErrMustBePositive, + err: commands.ErrMustBePositiveOrZero, }, { product: vegapb.UpdatePerpetualProduct{