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

Perps: check both funding payment and rate are non-zero before including pending funding payment in PositionEstimate #10122

Merged
merged 2 commits into from
Nov 17, 2023
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.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 2 additions & 0 deletions .spelling
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,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 @@ -38,6 +38,7 @@
- [10050](https://github.com/vegaprotocol/vega/issues/10050) - Cleanup `mempool` cache on commit.
- [10052](https://github.com/vegaprotocol/vega/issues/10052) - Some recent stats tables should have been `hypertables` with retention periods.
- [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.0

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 @@ -3248,7 +3248,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