Instant Opens enable you to open a position immediately by using a market order. This process leverages a prior SIWE login to obtain an access token and then uses that token to send your trade payload to the solver’s instant‑open endpoint.
Instant Trading is only for sending MARKET orders
1. Fetch the Current Price and Apply Slippage
Retrieve the asset price from Muon (returned in wei). Use the uPnL_A_WithSymbolPrice method to get this price.
// Fetch the asset price from Muon (price returned in wei)asyncfunctionfetchMuonPrice() {try {constresponse=awaitaxios.get(MUON_URL);constfetchedPriceWei=response.data.result.data.result.price;if (!fetchedPriceWei) {thrownewError("Muon price not found in response."); }return fetchedPriceWei; // as a string (in wei) } catch (error) {console.error("Error fetching Muon price:",error.response?.data ||error.message );throw error; }}
For LONG positions, you should increase the fetched price by a fixed percentage (e.g., +1%) to account for the hedger’s spread, for SHORT decrease the price by the same amount. This is the adjustedPrice that will be sent to the API endpoint. The adjusted price becomes the basis for calculating the notional value.
2. Fetch Locked Parameters
Query the solver’s get_locked_paramsendpoint to obtain CVA, LF, PartyAmm, and PartyBmm (provided as percentages). These parameters define the collateral requirements for the trade.
3. Calculate Notional Value
For MARKET orders, compute the notional value as: notionalValue = quantity * adjustedPrice
4. Compute Normalized Locked Values:
For each risk parameter (e.g., CVA, LF, PartyAmm, PartyBmm), the normalized locked value is calculated using the formula:
Normalized Locked Value (Wei) = (Notional Value × lockedParam) / (100 * leverage)
For partyBmm, leverage is not used in the calculation
price: The adjusted price (after applying slippage).
quantity: The trade quantity (in 18‑decimals).
cva, lf, partyAmm, partyBmm: The normalized locked values calculated above.
maxFundingRate: Maximum funding rate allowed by Party A (converted to 18 decimals).
deadline: A Unix timestamp indicating when the trade request expires. It's recommended to use a longer dated expiry (>1 day)
6. Send the Instant Open Request:
Use the access token obtained via SIWE login and send the trade payload to the /instant_open endpoint of the solver. This is done via an HTTP POST with appropriate headers.
Sample Script
Below is a simplified JavaScript example (using ethers and axios) that demonstrates the instant open flow using a LONG XRP order. This includes the login component: