From 839122706e53dea33fc48ff9ec42da4634c18213 Mon Sep 17 00:00:00 2001 From: Elias Van Ootegem Date: Mon, 7 Oct 2024 17:30:22 +0100 Subject: [PATCH] fix: division by zero fix Signed-off-by: Elias Van Ootegem --- CHANGELOG.md | 1 + core/execution/common/market_activity_tracker.go | 2 +- 2 files changed, 2 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 88c4560590..816f1a529a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -30,6 +30,7 @@ - [11696](https://github.com/vegaprotocol/vega/issues/11696) - Add binding for estimate fees API. - [11699](https://github.com/vegaprotocol/vega/issues/11699) - Update factors of programs when they are updated. - [11724](https://github.com/vegaprotocol/vega/issues/11724) - Allow nil initial time in time trigger. +- [11733](https://github.com/vegaprotocol/vega/issues/11733) - Fix division by zero. ## 0.78.2 diff --git a/core/execution/common/market_activity_tracker.go b/core/execution/common/market_activity_tracker.go index 0e9d1ea879..5ee66495ff 100644 --- a/core/execution/common/market_activity_tracker.go +++ b/core/execution/common/market_activity_tracker.go @@ -1427,7 +1427,7 @@ func (mt *marketTracker) processNotionalEndOfEpoch(epochStartTime time.Time, end for party, twNotional := range mt.twNotional { tn := int64(endEpochTime.Sub(twNotional.t).Seconds()) * scalingFactor var notional *num.Uint - if mt.markPrice != nil && !mt.markPrice.IsZero() { + if mt.markPrice != nil && !mt.markPrice.IsZero() && twNotional.price != nil && !twNotional.price.IsZero() { notional, _ = num.UintFromDecimal(twNotional.notional.ToDecimal().Div(twNotional.price.ToDecimal()).Mul(mt.markPrice.ToDecimal())) } else { notional = twNotional.notional