diff --git a/CHANGELOG.md b/CHANGELOG.md index eb0837bab3e..1a564ee1364 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -22,7 +22,8 @@ - [11066](https://github.com/vegaprotocol/vega/issues/11066) - Ensure vesting statistics match vesting accounts numbers. - [11279](https://github.com/vegaprotocol/vega/issues/11279) - Handle properly the case of multiple transfers for the same game id. - +- [11279](https://github.com/vegaprotocol/vega/issues/11279) - Handle properly the case of multiple transfers for the same game id. +- [11293](https://github.com/vegaprotocol/vega/issues/11293) - Panic in data node with position estimate endpoint. ## 0.76.1 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 2792af6edca..0262050ebec 100644 --- a/datanode/api/trading_data_v2.go +++ b/datanode/api/trading_data_v2.go @@ -3200,8 +3200,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( @@ -3219,22 +3219,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 } @@ -3460,7 +3461,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))