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

[API]: Update EstimatePosition API for fully collateralised FCAP markets #11452

Closed
cdummett opened this issue Jul 15, 2024 · 0 comments · Fixed by #11463
Closed

[API]: Update EstimatePosition API for fully collateralised FCAP markets #11452

cdummett opened this issue Jul 15, 2024 · 0 comments · Fixed by #11463

Comments

@cdummett
Copy link
Contributor

API Overview

In order to ... build deal tickets for FCAP markets
We will build an API to... that returns margin estimates
So that ... so the front end can return correct information

Currently the FCAP market does not return the correct margin requirements or liquidation prices for fully collateralised FCAP markets.

Screenshot 2024-07-15 at 09 31 40

The API should be updated to implement the following formulas when requesting estimates for a fully collateralised FCAP market:

Position margin

Note, as margin requirements are independent of the order book for a fully collateralised market, there is no need to distinguish between the best and worst case as any slippage is not considered in the calc.

  • $longMargin = averageEntryPrice * positionSize$

  • $shortMargin = (priceCap - averageEntryPrice) * positionSize$

Order margin

Note, for market orders use $price=markPrice$ and for limit orders use $price=limitPrice$.

  • $longOrderMargin = price * positionSize$

  • $shortOrderMargin = (priceCap - price) * positionSize$

Liquidation price

Note, will unlikely be unused in deal ticket but must be updated for completeness.

  • $longLiquidationPrice = 0$

  • $shortLiquidationPrice = priceCap$

Specs

https://github.com/vegaprotocol/specs/blob/colosseo_II/protocol/0019-MCAL-margin_calculator.md#fully-collateralised

Tests

API will be validated with market-sim tests in a similar fashion to the liquidation price tests.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Archived in project
Development

Successfully merging a pull request may close this issue.

2 participants