Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix/11293 #11294

Merged
merged 3 commits into from
May 18, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
2 changes: 1 addition & 1 deletion core/datasource/external/ethcall/engine.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
17 changes: 9 additions & 8 deletions datanode/api/trading_data_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand All @@ -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
}
Expand Down Expand Up @@ -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))
Expand Down
Loading