Orders
useOrderEntry
Order entry
The useOrderEntry
hook provides a variety of supporting functions according to input parameters and the prevailing market data.
Real-time data
useOrderEntry
provides some real-time data that the UI will use when creating orders based on the latest market data.
maxQty
: The maximum quantity that the user can trade based on the free collateral.freeCollateral
: The amount collateral available for trading, factoring in open positions and pending orders.markPrice
: The mark price of the symbol.estLiqPrice
: The estimated liquidation price, if a position is created from given order paramters.estLeverage
: The estimated leverage, if a position is created from given order paramters.
Note: Calculating
estLiqPrice
requires thewatchOrderbook
option to be set totrue
. It also depends on theorderbook:update
event emitted by theuseOrderbookStream
hook, which must be used elsewhere in your application.
Data calculations
The useOrderEntry
hook provides a calculate()
function to format user’s input:
- Converts the input quantity into USDC
- Truncates the input quantity and price according to the symbol’s tick size
Order validations
Order inputs should be validated by the frontend before submitting to provide the best user experience.