diff --git a/CHANGELOG.md b/CHANGELOG.md index d85ea8b743b..859caa12228 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -19,12 +19,20 @@ - [](https://github.com/vegaprotocol/vega/issues/xxx) +## 0.76.4 + +### 🐛 Fixes + +- [11293](https://github.com/vegaprotocol/vega/issues/11293) - Panic in data node with position estimate endpoint. + + ## 0.76.3 ### 🐛 Fixes - [11284](https://github.com/vegaprotocol/vega/pull/11284) - Do not account for started block in the past block range. + ## 0.76.2 ### 🐛 Fixes diff --git a/core/datasource/external/ethcall/engine.go b/core/datasource/external/ethcall/engine.go index 8a633ce28e1..be731d0e70d 100644 --- a/core/datasource/external/ethcall/engine.go +++ b/core/datasource/external/ethcall/engine.go @@ -321,7 +321,7 @@ func (e *Engine) Poll(ctx context.Context, wallTime time.Time) { if call.triggered(prevEthBlock, nextEthBlockIsh) { res, err := call.Call(ctx, e.client, nextEthBlock.Number.Uint64()) if err != nil { - e.log.Error("failed to call contract", logging.Error(err), logging.Uint64("chain-id", e.chainID.Load())) + e.log.Error("failed to call contract", logging.Error(err), logging.String("spec-id", specID), logging.Uint64("chain-id", e.chainID.Load())) event := makeErrorChainEvent(err.Error(), specID, nextEthBlockIsh, e.chainID.Load()) e.forwarder.ForwardFromSelf(event) e.lastSent = nextEthBlockIsh diff --git a/datanode/api/trading_data_v2.go b/datanode/api/trading_data_v2.go index ef8e86e64a5..9d6753031e2 100644 --- a/datanode/api/trading_data_v2.go +++ b/datanode/api/trading_data_v2.go @@ -3038,8 +3038,8 @@ func (t *TradingDataServiceV2) scaleFromMarketToAssetPrice( if err != nil { return nil, err } - - return price.Mul(price, priceFactor), nil + price, _ = num.UintFromDecimal(price.ToDecimal().Mul(priceFactor)) + return price, nil } func (t *TradingDataServiceV2) scaleDecimalFromMarketToAssetPrice( @@ -3057,22 +3057,23 @@ func (t *TradingDataServiceV2) scaleDecimalFromAssetToMarketPrice( func (t *TradingDataServiceV2) getMarketPriceFactor( ctx context.Context, mkt entities.Market, -) (*num.Uint, error) { +) (num.Decimal, error) { assetID, err := mkt.ToProto().GetAsset() if err != nil { - return nil, errors.Wrap(err, "getting asset from market") + return num.DecimalZero(), errors.Wrap(err, "getting asset from market") } asset, err := t.AssetService.GetByID(ctx, assetID) if err != nil { - return nil, errors.Wrapf(ErrAssetServiceGetByID, "assetID: %s", assetID) + return num.DecimalZero(), errors.Wrapf(ErrAssetServiceGetByID, "assetID: %s", assetID) } // scale the price if needed // price is expected in market decimal - priceFactor := num.NewUint(1) + priceFactor := num.DecimalOne() + // this could be negative, use decimal if exp := asset.Decimals - mkt.DecimalPlaces; exp != 0 { - priceFactor.Exp(num.NewUint(10), num.NewUint(uint64(exp))) + priceFactor = num.DecimalFromInt64(10).Pow(num.DecimalFromInt64(int64(exp))) } return priceFactor, nil } @@ -3298,7 +3299,7 @@ func (t *TradingDataServiceV2) EstimatePosition(ctx context.Context, req *v2.Est return nil, err } - dPriceFactor := priceFactor.ToDecimal() + dPriceFactor := priceFactor buyOrders := make([]*risk.OrderInfo, 0, len(req.Orders)) sellOrders := make([]*risk.OrderInfo, 0, len(req.Orders))