Skip to content

Commit

Permalink
Merge pull request #10122 from vegaprotocol/estimate-position-isolate…
Browse files Browse the repository at this point in the history
…d-fix

Perps: check both funding payment and rate are non-zero before including pending funding payment in PositionEstimate
  • Loading branch information
jeremyletang committed Nov 17, 2023
1 parent 373f141 commit e751121
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 1 deletion.
2 changes: 2 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,8 @@ mutexes
nodewallet
notarising
OpenRPC
perp
perps
phish
Prometheus
proto
Expand Down
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@

- [9940](https://github.com/vegaprotocol/vega/issues/9940) - Do not assume stop order is valid when generating ids up front.
- [10103](https://github.com/vegaprotocol/vega/issues/10103) - List ledgers `API` returns bad error when filtering by transfer type only.
- [10121](https://github.com/vegaprotocol/vega/issues/10121) - Assure `EstimatePosition` API works correctly with sparse perps data

## 0.73.4

Expand Down
6 changes: 5 additions & 1 deletion datanode/api/trading_data_v2.go
Original file line number Diff line number Diff line change
Expand Up @@ -3243,7 +3243,11 @@ func (t *TradingDataServiceV2) EstimatePosition(ctx context.Context, req *v2.Est
if err != nil {
return nil, formatE(fmt.Errorf("can't parse funding payment from perpetual product data: %s", perpData.FundingPayment), err)
}
if !fundingPayment.IsZero() {
fundingRate, err := num.DecimalFromString(perpData.FundingRate)
if err != nil {
return nil, formatE(fmt.Errorf("can't parse funding rate from perpetual product data: %s", perpData.FundingRate), err)
}
if !fundingPayment.IsZero() && !fundingRate.IsZero() {
marginFactorScaledFundingPaymentPerUnitPosition = factor.Mul(fundingPayment)
}
}
Expand Down

0 comments on commit e751121

Please sign in to comment.